Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
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
docker-py
Commits
dbe52dcb
Kaydet (Commit)
dbe52dcb
authored
Haz 05, 2018
tarafından
Joffrey F
Kaydeden (comit)
Joffrey F
Haz 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix socket reading function for TCP (non-HTTPS) connections on Windows
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
49bb7386
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
2 deletions
+59
-2
socket.py
docker/utils/socket.py
+3
-0
api_test.py
tests/unit/api_test.py
+56
-2
No files found.
docker/utils/socket.py
Dosyayı görüntüle @
dbe52dcb
import
errno
import
os
import
select
import
socket
as
pysocket
import
struct
import
six
...
...
@@ -28,6 +29,8 @@ def read(socket, n=4096):
try
:
if
hasattr
(
socket
,
'recv'
):
return
socket
.
recv
(
n
)
if
six
.
PY3
and
isinstance
(
socket
,
getattr
(
pysocket
,
'SocketIO'
)):
return
socket
.
read
(
n
)
return
os
.
read
(
socket
.
fileno
(),
n
)
except
EnvironmentError
as
e
:
if
e
.
errno
not
in
recoverable_errors
:
...
...
tests/unit/api_test.py
Dosyayı görüntüle @
dbe52dcb
...
...
@@ -365,7 +365,7 @@ class DockerApiTest(BaseAPIClientTest):
assert
result
==
content
class
StreamTest
(
unittest
.
TestCase
):
class
UnixSocket
StreamTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
socket_dir
=
tempfile
.
mkdtemp
()
self
.
build_context
=
tempfile
.
mkdtemp
()
...
...
@@ -462,7 +462,61 @@ class StreamTest(unittest.TestCase):
raise
e
assert
list
(
stream
)
==
[
str
(
i
)
.
encode
()
for
i
in
range
(
50
)]
str
(
i
)
.
encode
()
for
i
in
range
(
50
)
]
class
TCPSocketStreamTest
(
unittest
.
TestCase
):
text_data
=
b
'''
Now, those children out there, they're jumping through the
flames in the hope that the god of the fire will make them fruitful.
Really, you can't blame them. After all, what girl would not prefer the
child of a god to that of some acne-scarred artisan?
'''
def
setUp
(
self
):
self
.
server
=
six
.
moves
.
socketserver
.
ThreadingTCPServer
(
(
''
,
0
),
self
.
get_handler_class
()
)
self
.
thread
=
threading
.
Thread
(
target
=
self
.
server
.
serve_forever
)
self
.
thread
.
setDaemon
(
True
)
self
.
thread
.
start
()
self
.
address
=
'http://{}:{}'
.
format
(
socket
.
gethostname
(),
self
.
server
.
server_address
[
1
]
)
def
tearDown
(
self
):
self
.
server
.
shutdown
()
self
.
server
.
server_close
()
self
.
thread
.
join
()
def
get_handler_class
(
self
):
text_data
=
self
.
text_data
class
Handler
(
six
.
moves
.
BaseHTTPServer
.
BaseHTTPRequestHandler
,
object
):
def
do_POST
(
self
):
self
.
send_response
(
101
)
self
.
send_header
(
'Content-Type'
,
'application/vnd.docker.raw-stream'
)
self
.
send_header
(
'Connection'
,
'Upgrade'
)
self
.
send_header
(
'Upgrade'
,
'tcp'
)
self
.
end_headers
()
self
.
wfile
.
flush
()
time
.
sleep
(
0.2
)
self
.
wfile
.
write
(
text_data
)
self
.
wfile
.
flush
()
return
Handler
def
test_read_from_socket
(
self
):
with
APIClient
(
base_url
=
self
.
address
)
as
client
:
resp
=
client
.
_post
(
client
.
_url
(
'/dummy'
),
stream
=
True
)
data
=
client
.
_read_from_socket
(
resp
,
stream
=
True
,
tty
=
True
)
results
=
b
''
.
join
(
data
)
assert
results
==
self
.
text_data
class
UserAgentTest
(
unittest
.
TestCase
):
...
...
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