File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 10
10
import re
11
11
import sys
12
12
import threading
13
+ from StringIO import StringIO
13
14
14
15
import pytz
16
+ import six .moves
15
17
16
18
try :
17
19
import numpy
@@ -347,6 +349,27 @@ def is_source_key(key):
347
349
return False
348
350
349
351
352
+ # TODO: unclear if there's an async version to hook to our StreamReader.
353
+ class HttpResponseParser (object ):
354
+ """To parse a raw http response, we need to fake a socket."""
355
+
356
+ class FakeSocket (object ):
357
+ def __init__ (self , response_str ):
358
+ self ._file = StringIO (response_str )
359
+
360
+ def makefile (self , * args , ** kwargs ):
361
+ return self ._file
362
+
363
+ def __init__ (self , response_string ):
364
+ self .response_string = response_string
365
+
366
+ def get_response (self ):
367
+ sock = self .FakeSocket (self .response_string )
368
+ response = six .moves .http_client .HTTPResponse (sock )
369
+ response .begin ()
370
+ return response
371
+
372
+
350
373
class DisconnectThread (threading .Thread ):
351
374
"""Provides a disconnect api to communicate with threads."""
352
375
You can’t perform that action at this time.
0 commit comments