Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a79449e7
Commit
a79449e7
authored
Feb 15, 2004
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #711838: Allow non-anonymous ftp urls in urllib2.
Backported to 2.3.
parent
d3f4a1a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
Lib/urllib2.py
Lib/urllib2.py
+15
-6
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/urllib2.py
View file @
a79449e7
...
...
@@ -115,7 +115,7 @@ except ImportError:
# not sure how many of these need to be gotten rid of
from
urllib
import
unwrap
,
unquote
,
splittype
,
splithost
,
\
addinfourl
,
splitport
,
splitgophertype
,
splitquery
,
\
splitattr
,
ftpwrapper
,
noheaders
splitattr
,
ftpwrapper
,
noheaders
,
splituser
,
splitpasswd
# support for FileHandler, proxies via environment variables
from
urllib
import
localhost
,
url2pathname
,
getproxies
...
...
@@ -1090,21 +1090,30 @@ class FTPHandler(BaseHandler):
host
=
req
.
get_host
()
if
not
host
:
raise
IOError
,
(
'ftp error'
,
'no host given'
)
# XXX handle custom username & password
host
,
port
=
splitport
(
host
)
if
port
is
None
:
port
=
ftplib
.
FTP_PORT
# username/password handling
user
,
host
=
splituser
(
host
)
if
user
:
user
,
passwd
=
splitpasswd
(
user
)
else
:
passwd
=
None
host
=
unquote
(
host
)
user
=
unquote
(
user
or
''
)
passwd
=
unquote
(
passwd
or
''
)
try
:
host
=
socket
.
gethostbyname
(
host
)
except
socket
.
error
,
msg
:
raise
URLError
(
msg
)
host
,
port
=
splitport
(
host
)
if
port
is
None
:
port
=
ftplib
.
FTP_PORT
path
,
attrs
=
splitattr
(
req
.
get_selector
())
dirs
=
path
.
split
(
'/'
)
dirs
=
map
(
unquote
,
dirs
)
dirs
,
file
=
dirs
[:
-
1
],
dirs
[
-
1
]
if
dirs
and
not
dirs
[
0
]:
dirs
=
dirs
[
1
:]
user
=
passwd
=
''
# XXX
try
:
fw
=
self
.
connect_ftp
(
user
,
passwd
,
host
,
port
,
dirs
)
type
=
file
and
'I'
or
'D'
...
...
Misc/NEWS
View file @
a79449e7
...
...
@@ -237,6 +237,8 @@ Extension modules
Library
-------
-
Support
non
-
anonymous
ftp
URLs
in
urllib2
.
-
The
encodings
package
will
now
applies
codec
name
aliases
first
before
starting
to
try
the
import
of
the
codec
module
.
This
simplifies
overriding
built
-
in
codecs
with
external
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment