Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4eb5940a
Kaydet (Commit)
4eb5940a
authored
Tem 26, 2001
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Untabify IPv6 changes.
üst
2e441f78
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
126 deletions
+126
-126
ftplib.py
Lib/ftplib.py
+66
-66
httplib.py
Lib/httplib.py
+16
-16
poplib.py
Lib/poplib.py
+17
-17
smtplib.py
Lib/smtplib.py
+16
-16
telnetlib.py
Lib/telnetlib.py
+11
-11
No files found.
Lib/ftplib.py
Dosyayı görüntüle @
4eb5940a
...
@@ -109,28 +109,28 @@ class FTP:
...
@@ -109,28 +109,28 @@ class FTP:
if
user
:
self
.
login
(
user
,
passwd
,
acct
)
if
user
:
self
.
login
(
user
,
passwd
,
acct
)
def
connect
(
self
,
host
=
''
,
port
=
0
):
def
connect
(
self
,
host
=
''
,
port
=
0
):
'''Connect to host. Arguments are:
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
- host: hostname to connect to (string, default previous host)
- port: port to connect to (integer, default previous port)'''
- port: port to connect to (integer, default previous port)'''
if
host
:
self
.
host
=
host
if
host
:
self
.
host
=
host
if
port
:
self
.
port
=
port
if
port
:
self
.
port
=
port
self
.
passiveserver
=
0
self
.
passiveserver
=
0
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
.
connect
(
sa
)
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
self
.
sock
.
close
()
self
.
sock
.
close
()
self
.
sock
=
None
self
.
sock
=
None
continue
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
self
.
af
=
af
self
.
af
=
af
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
welcome
=
self
.
getresp
()
self
.
welcome
=
self
.
getresp
()
return
self
.
welcome
return
self
.
welcome
def
getwelcome
(
self
):
def
getwelcome
(
self
):
'''Get the welcome message from the server.
'''Get the welcome message from the server.
...
@@ -256,47 +256,47 @@ class FTP:
...
@@ -256,47 +256,47 @@ class FTP:
return
self
.
voidcmd
(
cmd
)
return
self
.
voidcmd
(
cmd
)
def
sendeprt
(
self
,
host
,
port
):
def
sendeprt
(
self
,
host
,
port
):
'''Send a EPRT command with the current host and the given port number.'''
'''Send a EPRT command with the current host and the given port number.'''
af
=
0
af
=
0
if
self
.
af
==
socket
.
AF_INET
:
if
self
.
af
==
socket
.
AF_INET
:
af
=
1
af
=
1
if
self
.
af
==
socket
.
AF_INET6
:
if
self
.
af
==
socket
.
AF_INET6
:
af
=
2
af
=
2
if
af
==
0
:
if
af
==
0
:
raise
error_proto
,
'unsupported address family'
raise
error_proto
,
'unsupported address family'
fields
=
[
''
,
`af`
,
host
,
`port`
,
''
]
fields
=
[
''
,
`af`
,
host
,
`port`
,
''
]
cmd
=
'EPRT '
+
string
.
joinfields
(
fields
,
'|'
)
cmd
=
'EPRT '
+
string
.
joinfields
(
fields
,
'|'
)
return
self
.
voidcmd
(
cmd
)
return
self
.
voidcmd
(
cmd
)
def
makeport
(
self
):
def
makeport
(
self
):
'''Create a new socket and send a PORT command for it.'''
'''Create a new socket and send a PORT command for it.'''
for
res
in
socket
.
getaddrinfo
(
None
,
0
,
self
.
af
,
socket
.
SOCK_STREAM
,
0
,
socket
.
AI_PASSIVE
):
for
res
in
socket
.
getaddrinfo
(
None
,
0
,
self
.
af
,
socket
.
SOCK_STREAM
,
0
,
socket
.
AI_PASSIVE
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
sock
.
bind
(
sa
)
sock
.
bind
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
sock
.
close
()
sock
.
close
()
sock
=
None
sock
=
None
continue
continue
break
break
if
not
sock
:
if
not
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
sock
.
listen
(
1
)
sock
.
listen
(
1
)
port
=
sock
.
getsockname
()[
1
]
# Get proper port
port
=
sock
.
getsockname
()[
1
]
# Get proper port
host
=
self
.
sock
.
getsockname
()[
0
]
# Get proper host
host
=
self
.
sock
.
getsockname
()[
0
]
# Get proper host
if
self
.
af
==
socket
.
AF_INET
:
if
self
.
af
==
socket
.
AF_INET
:
resp
=
self
.
sendport
(
host
,
port
)
resp
=
self
.
sendport
(
host
,
port
)
else
:
else
:
resp
=
self
.
sendeprt
(
host
,
port
)
resp
=
self
.
sendeprt
(
host
,
port
)
return
sock
return
sock
def
makepasv
(
self
):
def
makepasv
(
self
):
if
self
.
af
==
socket
.
AF_INET
:
if
self
.
af
==
socket
.
AF_INET
:
host
,
port
=
parse227
(
self
.
sendcmd
(
'PASV'
))
host
,
port
=
parse227
(
self
.
sendcmd
(
'PASV'
))
else
:
else
:
host
,
port
=
parse229
(
self
.
sendcmd
(
'EPSV'
),
self
.
sock
.
getpeername
())
host
,
port
=
parse229
(
self
.
sendcmd
(
'EPSV'
),
self
.
sock
.
getpeername
())
return
host
,
port
return
host
,
port
def
ntransfercmd
(
self
,
cmd
,
rest
=
None
):
def
ntransfercmd
(
self
,
cmd
,
rest
=
None
):
"""Initiate a transfer over the data connection.
"""Initiate a transfer over the data connection.
...
@@ -316,9 +316,9 @@ class FTP:
...
@@ -316,9 +316,9 @@ class FTP:
size
=
None
size
=
None
if
self
.
passiveserver
:
if
self
.
passiveserver
:
host
,
port
=
self
.
makepasv
()
host
,
port
=
self
.
makepasv
()
af
,
socktype
,
proto
,
canon
,
sa
=
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
)[
0
]
af
,
socktype
,
proto
,
canon
,
sa
=
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
)[
0
]
conn
=
socket
.
socket
(
af
,
socktype
,
proto
)
conn
=
socket
.
socket
(
af
,
socktype
,
proto
)
conn
.
connect
(
sa
)
conn
.
connect
(
sa
)
if
rest
is
not
None
:
if
rest
is
not
None
:
self
.
sendcmd
(
"REST
%
s"
%
rest
)
self
.
sendcmd
(
"REST
%
s"
%
rest
)
resp
=
self
.
sendcmd
(
cmd
)
resp
=
self
.
sendcmd
(
cmd
)
...
@@ -575,17 +575,17 @@ def parse229(resp, peer):
...
@@ -575,17 +575,17 @@ def parse229(resp, peer):
Return ('host.addr.as.numbers', port#) tuple.'''
Return ('host.addr.as.numbers', port#) tuple.'''
if
resp
[:
3
]
<>
'229'
:
if
resp
[:
3
]
<>
'229'
:
raise
error_reply
,
resp
raise
error_reply
,
resp
left
=
string
.
find
(
resp
,
'('
)
left
=
string
.
find
(
resp
,
'('
)
if
left
<
0
:
raise
error_proto
,
resp
if
left
<
0
:
raise
error_proto
,
resp
right
=
string
.
find
(
resp
,
')'
,
left
+
1
)
right
=
string
.
find
(
resp
,
')'
,
left
+
1
)
if
right
<
0
:
if
right
<
0
:
raise
error_proto
,
resp
# should contain '(|||port|)'
raise
error_proto
,
resp
# should contain '(|||port|)'
if
resp
[
left
+
1
]
<>
resp
[
right
-
1
]:
if
resp
[
left
+
1
]
<>
resp
[
right
-
1
]:
raise
error_proto
,
resp
raise
error_proto
,
resp
parts
=
string
.
split
(
resp
[
left
+
1
:
right
],
resp
[
left
+
1
])
parts
=
string
.
split
(
resp
[
left
+
1
:
right
],
resp
[
left
+
1
])
if
len
(
parts
)
<>
5
:
if
len
(
parts
)
<>
5
:
raise
error_proto
,
resp
raise
error_proto
,
resp
host
=
peer
[
0
]
host
=
peer
[
0
]
port
=
string
.
atoi
(
parts
[
3
])
port
=
string
.
atoi
(
parts
[
3
])
return
host
,
port
return
host
,
port
...
...
Lib/httplib.py
Dosyayı görüntüle @
4eb5940a
...
@@ -357,22 +357,22 @@ class HTTPConnection:
...
@@ -357,22 +357,22 @@ class HTTPConnection:
def
connect
(
self
):
def
connect
(
self
):
"""Connect to the host and port specified in __init__."""
"""Connect to the host and port specified in __init__."""
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
if
self
.
debuglevel
>
0
:
if
self
.
debuglevel
>
0
:
print
"connect: (
%
s,
%
s)"
%
(
self
.
host
,
self
.
port
)
print
"connect: (
%
s,
%
s)"
%
(
self
.
host
,
self
.
port
)
self
.
sock
.
connect
(
sa
)
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
if
self
.
debuglevel
>
0
:
if
self
.
debuglevel
>
0
:
print
'connect fail:'
,
(
self
.
host
,
self
.
port
)
print
'connect fail:'
,
(
self
.
host
,
self
.
port
)
self
.
sock
.
close
()
self
.
sock
.
close
()
self
.
sock
=
None
self
.
sock
=
None
continue
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
def
close
(
self
):
def
close
(
self
):
"""Close the connection to the HTTP server."""
"""Close the connection to the HTTP server."""
...
...
Lib/poplib.py
Dosyayı görüntüle @
4eb5940a
...
@@ -73,23 +73,23 @@ class POP3:
...
@@ -73,23 +73,23 @@ class POP3:
def
__init__
(
self
,
host
,
port
=
POP3_PORT
):
def
__init__
(
self
,
host
,
port
=
POP3_PORT
):
self
.
host
=
host
self
.
host
=
host
self
.
port
=
port
self
.
port
=
port
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
self
.
host
,
self
.
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
.
connect
(
sa
)
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
self
.
sock
.
close
()
self
.
sock
.
close
()
self
.
sock
=
None
self
.
sock
=
None
continue
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
file
=
self
.
sock
.
makefile
(
'rb'
)
self
.
_debugging
=
0
self
.
_debugging
=
0
self
.
welcome
=
self
.
_getresp
()
self
.
welcome
=
self
.
_getresp
()
def
_putline
(
self
,
line
):
def
_putline
(
self
,
line
):
...
...
Lib/smtplib.py
Dosyayı görüntüle @
4eb5940a
...
@@ -208,7 +208,7 @@ class SMTP:
...
@@ -208,7 +208,7 @@ class SMTP:
specified during instantiation.
specified during instantiation.
"""
"""
if
not
port
and
(
host
.
find
(
':'
)
==
host
.
rfind
(
':'
)):
if
not
port
and
(
host
.
find
(
':'
)
==
host
.
rfind
(
':'
)):
i
=
host
.
rfind
(
':'
)
i
=
host
.
rfind
(
':'
)
if
i
>=
0
:
if
i
>=
0
:
host
,
port
=
host
[:
i
],
host
[
i
+
1
:]
host
,
port
=
host
[:
i
],
host
[
i
+
1
:]
...
@@ -216,21 +216,21 @@ class SMTP:
...
@@ -216,21 +216,21 @@ class SMTP:
except
ValueError
:
except
ValueError
:
raise
socket
.
error
,
"nonnumeric port"
raise
socket
.
error
,
"nonnumeric port"
if
not
port
:
port
=
SMTP_PORT
if
not
port
:
port
=
SMTP_PORT
if
self
.
debuglevel
>
0
:
print
'connect:'
,
(
host
,
port
)
if
self
.
debuglevel
>
0
:
print
'connect:'
,
(
host
,
port
)
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
if
self
.
debuglevel
>
0
:
print
'connect:'
,
(
host
,
port
)
if
self
.
debuglevel
>
0
:
print
'connect:'
,
(
host
,
port
)
self
.
sock
.
connect
(
sa
)
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
if
self
.
debuglevel
>
0
:
print
'connect fail:'
,
(
host
,
port
)
if
self
.
debuglevel
>
0
:
print
'connect fail:'
,
(
host
,
port
)
self
.
sock
.
close
()
self
.
sock
.
close
()
self
.
sock
=
None
self
.
sock
=
None
continue
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
(
code
,
msg
)
=
self
.
getreply
()
(
code
,
msg
)
=
self
.
getreply
()
if
self
.
debuglevel
>
0
:
print
"connect:"
,
msg
if
self
.
debuglevel
>
0
:
print
"connect:"
,
msg
return
(
code
,
msg
)
return
(
code
,
msg
)
...
...
Lib/telnetlib.py
Dosyayı görüntüle @
4eb5940a
...
@@ -136,18 +136,18 @@ class Telnet:
...
@@ -136,18 +136,18 @@ class Telnet:
port
=
TELNET_PORT
port
=
TELNET_PORT
self
.
host
=
host
self
.
host
=
host
self
.
port
=
port
self
.
port
=
port
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
for
res
in
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
.
connect
(
sa
)
self
.
sock
.
connect
(
sa
)
except
socket
.
error
,
msg
:
except
socket
.
error
,
msg
:
self
.
sock
.
close
()
self
.
sock
.
close
()
self
.
sock
=
None
self
.
sock
=
None
continue
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
socket
.
error
,
msg
raise
socket
.
error
,
msg
def
__del__
(
self
):
def
__del__
(
self
):
"""Destructor -- close the connection."""
"""Destructor -- close the connection."""
...
...
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