Commits

Lynn Rees committed 7cf6767

- refactor

  • Participants
  • Parent commits 07e4c78
  • Branches next

Comments (0)

Files changed (33)

File wire/http/__init__.py

Empty file removed.

File wire/http/apps.py

+
+
+# HTTP clients
+HTTPLIST = dict(
+    urllib2='ul2_client.Request',
+    httplib2='hl2_client.Request',
+    pycurl='pycurl_client.Request',
+)
+#HTTP = Loader(HTTPLIST, package='wire.http.client')
+
+# REST clients
+RESTLIST = dict(
+    urllib2='ul2_client.REST',
+    httplib2='hl2_client.REST',
+    pycurl='pycurl_client.REST',
+)
+#REST = Loader(RESTLIST, package='wire.http.client')

File wire/http/client/__init__.py

Empty file removed.

File wire/http/client/app.py

-from wire.util import Loader
-
-# HTTP clients
-HTTPLIST = dict(
-    urllib2='ul2_client.Request',
-    httplib2='hl2_client.Request',
-    pycurl='pycurl_client.Request',
-)
-HTTP = Loader(HTTPLIST, package='wire.http.client')
-
-# REST clients
-RESTLIST = dict(
-    urllib2='ul2_client.REST',
-    httplib2='hl2_client.REST',
-    pycurl='pycurl_client.REST',
-)
-REST = Loader(RESTLIST, package='wire.http.client')

File wire/http/client/hl2_client.py

-'''httplib2 wire HTTP client wrapper'''
-
-#FIXME: don't import eventlet in test mode
-try:
-    import eventlet
-    httplib2 = eventlet.import_patched('httplib2')
-except ImportError:
-    import httplib2
-
-from wire.util import lazy, lazier
-from wire.http.response import CoreResponse
-from wire.http.request import CoreRequest, CoreREST
-
-
-class Response(CoreResponse):
-
-    '''httplib2 response object'''
-
-    def __init__(self, resp, **kw):
-        response, content = resp
-        self._hset('_original', content)
-        h = self._hset('_headers', dict(response))
-        self._hset('_code', h.pop('status', '500'))
-        self._hset('url', h.pop('content-location', None))
-        super(Response, self).__init__(**kw)
-
-
-class Request(CoreRequest):
-
-    def _factory(self):
-        auth = self._auth
-        proxy = self._proxy
-        if proxy:
-            try:
-                import socks
-                h = httplib2.Http(
-                    '.cache',
-                    proxy_info=httplib2.ProxyInfo(
-                        socks.PROXY_TYPE_HTTP, proxy['server'], proxy['host'],
-                    ),
-                )
-            except ImportError:
-                raise ImportWarning(
-                    u'httplib2 proxy support requires "socks" library'
-                )
-        else:
-            h = httplib2.Http('.cache')
-        if auth: h.add_credentials(*(auth['username'], auth['password']))
-        return h
-
-    def _request(self, **kw):
-        try:
-            factory = self._requestor
-            kw, newkw, respkw = self._kwfy(kw)
-            # temporary auth
-            auth = newkw.pop('auth', self._auth)
-            if auth: factory.add_credentials(
-                *(auth['username'], auth['password'])
-            )
-            # temporary timeout
-            factory.timeout = newkw.pop('timeout', self._timeout)
-            result = factory.request(
-                newkw.pop('url'),
-                method=kw.get('method', 'GET'),
-                body=newkw.pop('data', ''),
-                headers=dict(newkw.pop('headers')),
-            )
-            return self._response(result, **respkw)
-        except httplib2.RelativeURIError, e:
-            raise ValueError(e)
-        finally:
-            # clear temporary auth
-            if auth: factory.clear_credentials()
-            # clear temporary timeout
-            factory.timeout = None
-
-    @lazy
-    def _requestor(self):
-        return self._factory()
-
-    @lazier
-    def _response(self):
-        return Response
-
-
-class RESTClient(Request, CoreREST):
-
-    '''httplib2 REST client'''

File wire/http/client/pycurl_client.py

-'''p wire HTTP client wrapper'''
-
-from StringIO import StringIO
-from httplib import HTTPMessage
-# what pycurl needs...
-try:
-    import signal
-    from signal import SIGPIPE, SIG_IGN
-    signal.signal(SIGPIPE, SIG_IGN)
-except ImportError:
-    pass
-
-try:
-    import pycurl as p
-except ImportError:
-    raise ImportError('pycurl_client requires the "p" library')
-
-from wire.util import lazy, lazier
-from wire.http.response import CoreResponse
-from wire.http.request import CoreRequest, CoreREST
-
-
-class Request(CoreRequest):
-
-    @lazy
-    def _factory(self):
-        factory = p.Curl()
-        proxy = self._proxy
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY
-        if proxy:
-            factory.setopt(p.PROXY, ':'.join([proxy['server'], proxy['host']]))
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFOLLOWLOCATION
-        factory.setopt(p.FOLLOWLOCATION, 1)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTMAXREDIRS
-        factory.setopt(p.MAXREDIRS, 5)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT
-        factory.setopt(p.CONNECTTIMEOUT, 15)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL
-        factory.setopt(p.NOSIGNAL, 1)
-        # deprecated?
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTRANSFERTEXT
-        factory.setopt(p.TRANSFERTEXT, 1)
-        auth = self._auth
-        if auth:
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPAUTH
-            factory.setopt(p.HTTPAUTH, p.HTTPAUTH_BASIC)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERPWD
-            factory.setopt(
-                p.USERPWD, ':'.join(auth['username'], auth['password'])
-            )
-        return factory
-
-#    @lazy
-#    def multiple(self):
-#        def func(urls, **kw):
-#            multi = p.CurlMulti()
-#            makehandler = self._makehandler
-#            num_urls = len(urls)
-#            handlers = list(makehandler() for i in xrange(urls))
-#            return func
-
-    @lazier
-    def _response(self):
-        return Response
-
-#    def _makehandler(self, **kw):
-#        factory = p.Curl()
-#        getinfo = factory.getinfo
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFOLLOWLOCATION
-#        factory.setopt(p.FOLLOWLOCATION, 1)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTMAXREDIRS
-#        factory.setopt(p.MAXREDIRS, 5)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT
-#        factory.setopt(p.CONNECTTIMEOUT, 15)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL
-#        factory.setopt(p.NOSIGNAL, 1)
-#        # deprecated?
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTTRANSFERTEXT
-#        factory.setopt(p.TRANSFERTEXT, 1)
-#        # handle proxy
-#        proxy = kw.get('proxy', self._proxy)
-#        if proxy:
-#            factory.setopt(
-#                p.PROXY, ':'.join([proxy['server'], proxy['host']]),
-#            )
-#            # handle proxy auth
-#            factory.setopt(p.PROXYAUTH, p.HTTPAUTH_BASIC)
-#        # handle auth
-#        auth = kw.get('auth', self._auth)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERPWD
-#        if auth:
-#            factory.setopt(p.HTTPAUTH, p.HTTPAUTH_BASIC)
-#            factory.setopt(
-#                p.USERPWD, ':'.join(auth['username'], auth['password'])
-#            )
-#        # handle timeout
-#        timeout = kw.get('timeout', self._timeout)
-#        if timeout: factory.setopt(p.TIMEOUT, timeout)
-#        data = kw.get('data', '')
-#        # handle method
-#        method = kw.get('method', 'get').lower()
-#        headers = list(
-#            ': '.join(i) for i in kw.get('headers', list(self.h))
-#        )
-#        if method == 'post':
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOST
-#            factory.setopt(p.POST, 1)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDS
-#            factory.setopt(p.POSTFIELDS, data)
-#        elif method == 'put':
-#            # deprecated in favor of UPLOAD?
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPUT
-#            factory.setopt(p.PUT, 1)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUPLOAD
-#            factory.setopt(p.UPLOAD, 1)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTINFILESIZE
-#            factory.setopt(p.INFILESIZE, len(data))
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADDATA
-#            factory.setopt(p.READDATA, data)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOBODY
-#        elif method == 'head':
-#            factory.setopt(p.NOBODY, 1)
-## http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCUSTOMREQUEST
-#        elif method == 'delete':
-#            factory.setopt(p.CUSTOMREQUEST, 'DELETE')
-#        elif method == 'options':
-#            factory.setopt(p.CUSTOMREQUEST, 'OPTIONS')
-#        return factory
-
-    def _request(self, **kw):
-        try:
-            factory = self._factory
-            getinfo = factory.getinfo
-            # handle proxy
-            proxy = kw.pop('proxy', self._proxy)
-            if proxy:
-                factory.setopt(
-                    p.PROXY, ':'.join([proxy['server'], proxy['host']]),
-                )
-                # handle proxy auth
-                factory.setopt(p.PROXYAUTH, p.HTTPAUTH_BASIC)
-            # handle auth
-            auth = kw.pop('auth', self._auth)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERPWD
-            if auth:
-                factory.setopt(
-                    p.USERPWD, ':'.join([auth['username'], auth['password']])
-                )
-            # handle timeout
-            timeout = kw.pop('timeout', self._timeout)
-            if timeout: factory.setopt(p.TIMEOUT, timeout)
-            data = kw.pop('data', '')
-            # handle method
-            method = kw.pop('method', 'get').lower()
-            headers = list(
-                ': '.join(i) for i in kw.pop('headers', list(self.headers))
-            )
-            if method == 'post':
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOST
-                factory.setopt(p.POST, 1)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDS
-                factory.setopt(p.POSTFIELDS, data)
-            elif method == 'put':
-                # deprecated in favor of UPLOAD?
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPUT
-                factory.setopt(p.PUT, 1)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUPLOAD
-                factory.setopt(p.UPLOAD, 1)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTINFILESIZE
-                factory.setopt(p.INFILESIZE, len(data))
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADDATA
-                factory.setopt(p.READDATA, data)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOBODY
-            elif method == 'head':
-                factory.setopt(p.NOBODY, 1)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCUSTOMREQUEST
-            elif method == 'delete':
-                factory.setopt(p.CUSTOMREQUEST, 'DELETE')
-            elif method == 'options':
-                factory.setopt(p.CUSTOMREQUEST, 'OPTIONS')
-            # handle headers
-            header = StringIO()
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTUSERAGENT
-            factory.setopt(p.USERAGENT, self.headers.user_agent)
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPHEADER
-            factory.setopt(p.HTTPHEADER, list(headers))
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHEADERFUNCTION
-            factory.setopt(p.HEADERFUNCTION, header.write)
-            # handle data
-            body = StringIO()
-# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEFUNCTION
-            factory.setopt(p.WRITEFUNCTION, body.write)
-            # handle url
-            factory.setopt(p.URL, kw.pop('url'))
-            factory.perform()
-# INFO: http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html
-            result = dict(
-                headers=header,
-                data=data,
-                status=getinfo(p.HTTP_CODE),
-                content_location=getinfo(p.EFFECTIVE_URL),
-            )
-        except p.error, e:
-# INFO: http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html
-            result = dict(
-                headers=header,
-                data=data,
-                status=getinfo(p.HTTP_CODE),
-                url=getinfo(p.EFFECTIVE_URL),
-                redirect_url=getinfo(p.REDIRECT_URL),
-                errors='{0} {1}'.format(e[0], e[1]),
-            )
-        finally:
-            factory.close()
-        return result
-
-
-class RESTClient(Request, CoreREST):
-
-    '''pycurl REST client'''
-
-
-class Response(CoreResponse):
-
-    '''pycurl response object'''
-
-    def __init__(self, resp, **kw):
-        # data
-        data = resp.pop('data', StringIO())
-        data.seek(0)
-        # preserve original data
-        self._original = data.read()
-        # headers...
-        headers = resp.pop('headers', StringIO())
-        headers.seek(0)
-        # clear first status line
-        headers.readline()
-        # yum...headers
-        self._headers = h = dict(i for i in HTTPMessage(headers).items())
-        # it's an int
-        self._code = str(h.pop('status', 500))
-        # final url
-        self.url = h.pop('url', None)
-        super(Response, self).__init__(**kw)
-
-
-#m = pycurl.CurlMulti()
-#m.handles = []
-#for i in range(num_conn):
-#    c = pycurl.Curl()
-#    c.fp = None
-#    c.setopt(pycurl.FOLLOWLOCATION, 1)
-#    c.setopt(pycurl.MAXREDIRS, 5)
-#    c.setopt(pycurl.CONNECTTIMEOUT, 30)
-#    c.setopt(pycurl.TIMEOUT, 300)
-#    c.setopt(pycurl.NOSIGNAL, 1)
-#    m.handles.append(c)
-#
-#
-## Main loop
-#freelist = m.handles[:]
-#num_processed = 0
-#while num_processed < num_urls:
-#    # If there is an url to process and a free curl object, add to multi stack
-#    while queue and freelist:
-#        url, filename = queue.pop(0)
-#        c = freelist.pop()
-#        c.fp = open(filename, "wb")
-#        c.setopt(pycurl.URL, url)
-#        c.setopt(pycurl.WRITEDATA, c.fp)
-#        m.add_handle(c)
-#        # store some info
-#        c.filename = filename
-#        c.url = url
-#    # Run the internal curl state machine for the multi stack
-#    while 1:
-#        ret, num_handles = m.perform()
-#        if ret != pycurl.E_CALL_MULTI_PERFORM:
-#            break
-#    # Check for curl objects which have terminated, and add them to the freelist
-#    while 1:
-#        num_q, ok_list, err_list = m.info_read()
-#        for c in ok_list:
-#            c.fp.close()
-#            c.fp = None
-#            m.remove_handle(c)
-#            print "Success:", c.filename, c.url, c.getinfo(pycurl.EFFECTIVE_URL)
-#            freelist.append(c)
-#        for c, errno, errmsg in err_list:
-#            c.fp.close()
-#            c.fp = None
-#            m.remove_handle(c)
-#            print "Failed: ", c.filename, c.url, errno, errmsg
-#            freelist.append(c)
-#        num_processed = num_processed + len(ok_list) + len(err_list)
-#        if num_q == 0:
-#            break
-#    # Currently no more I/O is pending, could do something in the meantime
-#    # (display a progress bar, etc.).
-#    # We just call select() to sleep until some more data is available.
-#    m.select(1.0)
-#
-#
-## Cleanup
-#for c in m.handles:
-#    if c.fp is not None:
-#        c.fp.close()
-#        c.fp = None
-#    c.close()
-#m.close()

File wire/http/client/test/__init__.py

Empty file removed.

File wire/http/client/test/test_hl2.py

-import unittest
-from datetime import datetime
-
-import httplib2
-
-from wsgi_intercept import httplib2_intercept
-
-from wire.http.client.test.test_util import BaseMockHttpServer
-
-httplib2.debuglevel = 1
-
-
-class MockHttpServer(BaseMockHttpServer):
-
-    def __init__(self, port=80, auth=False):
-        super(MockHttpServer, self).__init__(port, auth)
-        httplib2_intercept.install()
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2HTTPUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(80)
-
-    def test_http_delete(self):
-        from wire.http import delete
-        r = delete('http://localhost:80/deleteable/')
-        self.assertEqual(
-            r.headers.date,
-            datetime(2011, 3, 15, 12, 10, 00),
-            r.headers.date,
-        )
-        self.assertEqual(r.code, 204)
-        self.assertEqual(r.status, '204 No Content')
-        self.assertEqual(r.data, '')
-
-    def test_http_get(self):
-        from wire.http import get
-        r = get('http://localhost:80/getable/')
-        self.assertEqual(r.code, 200)
-        self.assertEqual(r.status, '200 OK')
-        self.assertDictEqual(
-            dict(json='test', verify=True, array=[1, 2, 3]), r.json
-        )
-        self.assertEqual(
-            r.headers.date,
-            datetime(2011, 3, 15, 12, 10, 00),
-            r.headers.date,
-        )
-
-    def test_http_head(self):
-        from wire.http import head
-        r = head('http://localhost:80/headable/')
-        self.assertEqual(r.code, 200)
-
-    def test_http_options(self):
-        from wire.http import options
-        r = options('http://localhost:80/optionable/')
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'http://localhost:80/postable/', data=body,  format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'http://localhost:80/putable/', data=body, format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-
-class TestHL2HTTPAuthUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(80, auth=True)
-
-    def test_auth_http_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/deleteable/'
-        r = delete(url, auth=auth)
-        self.assertEqual(r.code, 204)
-        r = delete(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/getable/'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
-            dict(json='test', verify=True, array=[1, 2, 3]),
-            r.json
-        )
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_head(self):
-        from wire.http import head
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/headable/'
-        r = head(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = head(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/optionable/'
-        r = options(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = options(url)
-        self.assertEqual(r.code, 401)
-
-    def test_http_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://localhost:80/postable/'
-        r = post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = post(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://localhost:80/putable/'
-        auth = dict(username='test', password='test')
-        r = put(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = put(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-
-class TestHL2HTTPSUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(443)
-
-    def test_https_delete(self):
-        from wire.http import delete
-        r = delete('https://localhost:443/deleteable/')
-        self.assertEqual(r.code, 204)
-
-    def test_https_get(self):
-        from wire.http import get
-        r = get('https://localhost:443/getable/')
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r.json
-        )
-
-    def test_https_head(self):
-        from wire.http import head
-        r = head('https://localhost:443/headable/')
-        self.assertEqual(r.code, 200)
-
-    def test_https_options(self):
-        from wire.http import options
-        r = options('https://localhost:443/optionable/')
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'https://localhost:443/postable/', data=body,  format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'https://localhost:443/putable/', data=body, format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-
-class TestHL2HTTPSAuthUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(443, auth=True)
-
-    def test_auth_https_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/deleteable'
-        r = delete(url, auth=auth)
-        self.assertEqual(r.code, 204)
-        r = delete(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/getable/'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_head(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/headable/'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/putable/'
-        r = options(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = options(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://localhost:443/postable/'
-        r = post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = post(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://localhost:443/putable/'
-        auth = dict(username='test', password='test')
-        r = put(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = put(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2FastHTTPUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(80)
-
-    def test_http_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete('http://localhost:80/deleteable/')
-        self.assertEqual(r, 204, r)
-
-    def test_http_get(self):
-        from wire.http import fast_get
-        r = fast_get('http://localhost:80/getable/')
-        self.assertDictEqual(
-            dict(json='test', verify=True, array=[1, 2, 3]), r, r
-        )
-
-    def test_http_head(self):
-        from wire.http import fast_head
-        r = fast_head('http://localhost:80/headable/')
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_http_options(self):
-        from wire.http import fast_options
-        r = fast_options('http://localhost:80/optionable/')
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'http://localhost:80/postable/', data=body, format='json',
-        )
-        self.assertEqual(r, {'thing': 1, 'finished': True}, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_put(
-            'http://localhost:80/putable/', data=body, format='json',
-        )
-        self.assertDictEqual(r, {'thing': 1, 'finished': True}, r)
-
-
-class TestHL2FastHTTPAuthUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(80, auth=True)
-
-    def test_auth_http_delete(self):
-        from wire.http import fast_delete
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/deleteable/'
-        r = fast_delete(url, auth=auth)
-        self.assertEqual(r, 204, r)
-        r = fast_delete(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_http_get(self):
-        from wire.http import fast_get
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/getable/'
-        r = fast_get(url, auth=auth)
-        self.assertDictEqual(
-            dict(json='test', verify=True, array=[1, 2, 3]), r, r,
-        )
-        r = fast_get(url)
-        self.assertEquals(r, 401, r)
-
-    def test_auth_http_head(self):
-        from wire.http import fast_head
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/headable/'
-        r = fast_head(url, auth=auth)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-        r = fast_head(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import fast_options
-        auth = dict(username='test', password='test')
-        url = 'http://localhost:80/optionable/'
-        r = fast_options(url, auth=auth)
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'])
-        r = fast_options(url)
-        self.assertEqual(r, 401)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://localhost:80/postable/'
-        r = fast_post(url, data=body, auth=auth, format='json')
-        self.assertEqual({'thing': 1, 'finished': True}, r)
-        r = fast_post(url, data=body, format='json')
-        self.assertEqual(r, 401, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://localhost:80/putable/'
-        auth = dict(username='test', password='test')
-        r = fast_put(url, data=body, auth=auth, format='json')
-        self.assertDictEqual(r, {'thing': 1, 'finished': True})
-        r = fast_put(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-
-class TestHL2FastHTTPSUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(443)
-
-    def test_https_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete('https://localhost:443/deleteable/')
-        self.assertEqual(r, 204)
-
-    def test_https_get(self):
-        from wire.http import fast_get
-        r = fast_get('https://localhost:443/getable/')
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]),
-            r,
-            r
-        )
-
-    def test_https_head(self):
-        from wire.http import fast_head
-        r = fast_head('https://localhost:443/headable/')
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_https_options(self):
-        from wire.http import fast_options
-        r = fast_options('https://localhost:443/optionable/')
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_https_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'https://localhost:443/postable/', data=body, format='json',
-        )
-        self.assertEqual(r, {'thing': 1, 'finished': True}, r)
-
-    def test_https_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_put(
-            'https://localhost:443/putable/', data=body, format='json',
-        )
-        self.assertEqual(r, {'thing': 1, 'finished': True}, r)
-
-
-class TestHL2FastHTTPSAuthUnit(unittest.TestCase):
-
-    def setUp(self):
-        self.server = MockHttpServer(443, auth=True)
-
-    def test_auth_https_delete(self):
-        from wire.http import fast_delete
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/deleteable'
-        r = fast_delete(url, auth=auth)
-        self.assertEqual(r, 204)
-        r = fast_delete(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_https_get(self):
-        from wire.http import fast_get
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/getable/'
-        r = fast_get(url, auth=auth)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r
-        )
-        r = fast_get(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_https_head(self):
-        from wire.http import fast_head
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/headable/'
-        r = fast_head(url, auth=auth)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json',
-            'server': 'Fake Server 1.0'},
-            r
-        )
-        r = fast_head(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_https_options(self):
-        from wire.http import fast_options
-        auth = dict(username='test', password='test')
-        url = 'https://localhost:443/putable/'
-        r = fast_options(url, auth=auth)
-        self.assertEqual(r, ['GET' , 'OPTIONS', 'POST'])
-        r = fast_options(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_https_post(self):
-        from wire.http import fast_post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://localhost:443/postable/'
-        r = fast_post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r, {'thing': 1, 'finished': True})
-        r = fast_post(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-    def test_auth_https_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://localhost:443/putable/'
-        auth = dict(username='test', password='test')
-        r = fast_put(url, data=body, auth=auth, format='json')
-        self.assertDictEqual(r, {'thing': 1, 'finished': True} )
-        r = fast_put(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-
-if __name__ == '__main__':  unittest.main()

File wire/http/client/test/test_ihl2.py

-import unittest
-from datetime import datetime
-
-import httplib2
-
-httplib2.debuglevel = 1
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2HTTPUnit(unittest.TestCase):
-
-    def test_http_delete(self):
-        from wire.http import delete
-        r = delete('http://httpbin.org')
-#        self.assertEqual(
-#            r.headers.date,
-#            datetime(2011, 3, 15, 12, 10, 00),
-#            r.headers.date,
-#        )
-        self.assertEqual(r.code, 204)
-        self.assertEqual(r.status, '204 No Content')
-        self.assertEqual(r.data, '')
-
-    def test_http_get(self):
-        from wire.http import get
-        r = get('http://httpbin.org/get')
-        self.assertEqual(r.code, 200)
-        self.assertEqual(r.status, '200 OK')
-        self.assertDictEqual(
-            {'args': {},
-              'headers': {'Accept-Encoding': 'gzip, deflate',
-                          'Connection': 'close',
-                          'Content-Length': '',
-                          'Content-Type': '',
-                          'Host': 'httpbin.org',
-                          'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-                          'X-Forwarded-For': '::ffff:76.27.119.104',
-                          'X-Forwarded-Protocol': ''},
-              'origin': '::ffff:76.27.119.104',
-              'url': 'http://httpbin.org/get'},
-            r.json
-        )
-#        self.assertEqual(
-#            r.headers.date,
-#            datetime(2011, 3, 15, 12, 10, 00),
-#            r.headers.date,
-#        )
-
-    def test_http_head(self):
-        from wire.http import head
-        r = head('http://httpbin.org/head')
-        self.assertEqual(r.code, 200)
-
-    def test_http_options(self):
-        from wire.http import options
-        r = options('http://httpbin.org/option')
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'http://httpbin.org/post', data=body, format='json',
-        )
-        self.assertEqual(r.code, 200)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'http://httpbin.org/put', data=body, format='json',
-        )
-        self.assertEqual(r.code, 200)
-
-
-class TestHL2HTTPAuthUnit(unittest.TestCase):
-
-    def test_auth_http_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org'
-        r = delete(url, auth=auth)
-        self.assertEqual(r.code, 204)
-        r = delete(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/get'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
- {'args': {},
- 'headers': {'Accept-Encoding': 'gzip, deflate',
- 'Connection': 'close',
- 'Content-Length': '',
- 'Content-Type': '',
- 'Host': 'httpbin.org',
- 'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
- 'X-Forwarded-For': '::ffff:76.27.119.104',
- 'X-Forwarded-Protocol': ''},
- 'origin': '::ffff:76.27.119.104',
- 'url': 'http://httpbin.org/get'},
-            r.json
-        )
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_head(self):
-        from wire.http import head
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/headable/'
-        r = head(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = head(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/option'
-        r = options(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = options(url)
-        self.assertEqual(r.code, 401)
-
-    def test_http_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/post'
-        r = post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 200)
-        r = post(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/put'
-        auth = dict(username='test', password='test')
-        r = put(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 200)
-        r = put(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-
-class TestHL2HTTPSUnit(unittest.TestCase):
-
-    def test_https_delete(self):
-        from wire.http import delete
-        r = delete('https://httpbin.ep.io/delete')
-        self.assertEqual(r.code, 204)
-
-    def test_https_get(self):
-        from wire.http import get
-        r = get('https://httpbin.ep.io/get')
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r.json
-        )
-
-    def test_https_head(self):
-        from wire.http import head
-        r = head('https://httpbin.ep.io/headable/')
-        self.assertEqual(r.code, 200)
-
-    def test_https_options(self):
-        from wire.http import options
-        r = options('https://httpbin.ep.io/option')
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'https://httpbin.ep.io/post', data=body, format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'https://httpbin.ep.io/put', data=body, format='json',
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-
-class TestHL2HTTPSAuthUnit(unittest.TestCase):
-
-    def test_auth_https_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/delete'
-        r = delete(url, auth=auth)
-        self.assertEqual(r.code, 204)
-        r = delete(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/get'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_head(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/headable/'
-        r = get(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = get(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/put'
-        r = options(url, auth=auth)
-        self.assertEqual(r.code, 200)
-        r = options(url)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/post'
-        r = post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = post(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/put'
-        auth = dict(username='test', password='test')
-        r = put(url, data=body, auth=auth, format='json')
-        self.assertEqual(r.code, 201)
-        r = put(url, data=body, format='json')
-        self.assertEqual(r.code, 401)
-
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2FastHTTPUnit(unittest.TestCase):
-
-    maxDiff = None
-
-    def test_http_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete('http://httpbin.org/delete')
-        self.assertEqual(r, 200, r)
-
-    def test_http_get(self):
-        from wire.http import fast_get
-        r = fast_get('http://httpbin.org/get')
-        self.assertDictEqual(
-            {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/post', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'},
-            r,
-        )
-
-    def test_http_head(self):
-        from wire.http import fast_head
-        r = fast_head('http://httpbin.org/head')
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_http_options(self):
-        from wire.http import fast_options
-        r = fast_options('http://httpbin.org/option')
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'http://httpbin.org/post', data=body, format='json',
-        )
-        self.assertEqual(r, {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/post', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'}, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_put(
-            'http://httpbin.org/put', data=body, format='json',
-        )
-        self.assertDictEqual(
-            r,
-            {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/put', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'}
-        )
-
-
-class TestHL2FastHTTPAuthUnit(unittest.TestCase):
-
-    maxDiff = None
-
-    def test_auth_http_delete(self):
-        from wire.http import fast_delete
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/delete'
-        r = fast_delete(url, auth=auth)
-        self.assertEqual(r, 200, r)
-        r = fast_delete(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_http_get(self):
-        from wire.http import fast_get
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/get'
-        r = fast_get(url, auth=auth)
-        self.assertDictEqual(
-            {'origin': '::ffff:76.27.119.104', 'headers': {'Content-Length': '', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': ''}, 'args': {}, 'url': 'http://httpbin.org/get'}, r, r,
-        )
-        r = fast_get(url)
-        self.assertEquals(r, 401, r)
-
-    def test_auth_http_head(self):
-        from wire.http import fast_head
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/headable/'
-        r = fast_head(url, auth=auth)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-        r = fast_head(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import fast_options
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/option'
-        r = fast_options(url, auth=auth)
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'])
-        r = fast_options(url)
-        self.assertEqual(r, 401)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/post'
-        r = fast_post(url, data=body, auth=auth, format='json')
-        self.assertEqual(
-            {'args': {},
-  'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"',
-  'files': {},
-  'form': {},
-  'headers': {'Accept': 'application/json',
-              'Accept-Encoding': 'gzip, deflate',
-              'Connection': 'close',
-              'Content-Length': '62',
-              'Content-Type': 'application/json',
-              'Host': 'httpbin.org',
-              'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-              'X-Forwarded-For': '::ffff:76.27.119.104',
-              'X-Forwarded-Protocol': ''},
-  'origin': '::ffff:76.27.119.104',
-  'url': 'http://httpbin.org/post'}, r)
-        r = fast_post(url, data=body, format='json')
-        self.assertEqual(r, 401, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/put'
-        auth = dict(username='test', password='test')
-        r = fast_put(url, data=body, auth=auth, format='json')
-        self.assertDictEqual(
-            r,
-            {'args': {},
-  'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"',
-  'files': {},
-  'form': {},
-  'headers': {'Accept': 'application/json',
-              'Accept-Encoding': 'gzip, deflate',
-              'Connection': 'close',
-              'Content-Length': '62',
-              'Content-Type': 'application/json',
-              'Host': 'httpbin.org',
-              'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-              'X-Forwarded-For': '::ffff:76.27.119.104',
-              'X-Forwarded-Protocol': ''},
-  'origin': '::ffff:76.27.119.104',
-  'url': 'http://httpbin.org/put'})
-        r = fast_put(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-
-class TestHL2FastHTTPSUnit(unittest.TestCase):
-
-    def test_https_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete('https://httpbin.ep.io/delete')
-        self.assertEqual(r, 204)
-
-    def test_https_get(self):
-        from wire.http import fast_get
-        r = fast_get('https://httpbin.ep.io/get')
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r, r
-        )
-
-    def test_https_head(self):
-        from wire.http import fast_head
-        r = fast_head('https://httpbin.ep.io/headable/')
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_https_options(self):
-        from wire.http import fast_options
-        r = fast_options('https://httpbin.ep.io/option')
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_https_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'https://httpbin.ep.io/post', data=body, format='json',
-        )
-        self.assertEqual(r, {'thing': 1, 'finished': True}, r)
-
-    def test_https_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_put(
-            'https://httpbin.ep.io/put', data=body, format='json',
-        )
-        self.assertEqual(r, {'thing': 1, 'finished': True}, r)
-
-
-class TestHL2FastHTTPSAuthUnit(unittest.TestCase):
-
-    def test_auth_https_delete(self):
-        from wire.http import fast_delete
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/deleteable'
-        r = fast_delete(url, auth=auth)
-        self.assertEqual(r, 204)
-        r = fast_delete(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_https_get(self):
-        from wire.http import fast_get
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/get'
-        r = fast_get(url, auth=auth)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r
-        )
-        r = fast_get(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_https_head(self):
-        from wire.http import fast_head
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/headable/'
-        r = fast_head(url, auth=auth)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json',
-            'server': 'Fake Server 1.0'},
-            r
-        )
-        r = fast_head(url)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_https_options(self):
-        from wire.http import fast_options
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/put'
-        r = fast_options(url, auth=auth)
-        self.assertEqual(r, ['GET' , 'OPTIONS', 'POST'])
-        r = fast_options(url)
-        self.assertEqual(r, 401)
-
-    def test_auth_https_post(self):
-        from wire.http import fast_post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/post'
-        r = fast_post(url, data=body, auth=auth, format='json')
-        self.assertEqual(r, {'thing': 1, 'finished': True})
-        r = fast_post(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-    def test_auth_https_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/put'
-        auth = dict(username='test', password='test')
-        r = fast_put(url, data=body, auth=auth, format='json')
-        self.assertDictEqual(r, {'thing': 1, 'finished': True})
-        r = fast_put(url, data=body, format='json')
-        self.assertEqual(r, 401)
-
-
-if __name__ == '__main__':  unittest.main()

File wire/http/client/test/test_iul2.py

-import unittest
-from datetime import datetime
-
-import httplib2
-
-httplib2.debuglevel = 1
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2HTTPUnit(unittest.TestCase):
-
-    def test_http_delete(self):
-        from wire.http import delete
-        r = delete('http://httpbin.org', client='urllib2', test=True)
-        self.assertEqual(r.code, 204)
-        self.assertEqual(r.status, '204 No Content')
-        self.assertEqual(r.data, '')
-
-    def test_http_get(self):
-        from wire.http import get
-        r = get('http://httpbin.org/get', client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        self.assertEqual(r.status, '200 OK')
-        self.assertDictEqual(
-            {'args': {},
-              'headers': {'Accept-Encoding': 'gzip, deflate',
-                          'Connection': 'close',
-                          'Content-Length': '',
-                          'Content-Type': '',
-                          'Host': 'httpbin.org',
-                          'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-                          'X-Forwarded-For': '::ffff:76.27.119.104',
-                          'X-Forwarded-Protocol': ''},
-              'origin': '::ffff:76.27.119.104',
-              'url': 'http://httpbin.org/get'},
-            r.json
-        )
-#        self.assertEqual(
-#            r.headers.date,
-#            datetime(2011, 3, 15, 12, 10, 00),
-#            r.headers.date,
-#        )
-
-    def test_http_head(self):
-        from wire.http import head
-        r = head('http://httpbin.org/head', client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-
-    def test_http_options(self):
-        from wire.http import options
-        r = options('http://httpbin.org/option', client='urllib2', test=True)
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'http://httpbin.org/post',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True,
-        )
-        self.assertEqual(r.code, 200)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'http://httpbin.org/put',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True,
-        )
-        self.assertEqual(r.code, 200)
-
-
-class TestHL2HTTPAuthUnit(unittest.TestCase):
-
-    def test_auth_http_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org'
-        r = delete(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 204)
-        r = delete(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/get'
-        r = get(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
- {'args': {},
- 'headers': {'Accept-Encoding': 'gzip, deflate',
- 'Connection': 'close',
- 'Content-Length': '',
- 'Content-Type': '',
- 'Host': 'httpbin.org',
- 'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
- 'X-Forwarded-For': '::ffff:76.27.119.104',
- 'X-Forwarded-Protocol': ''},
- 'origin': '::ffff:76.27.119.104',
- 'url': 'http://httpbin.org/get'},
-            r.json
-        )
-        r = get(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_head(self):
-        from wire.http import head
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/headable/'
-        r = head(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        r = head(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/option'
-        r = options(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        r = options(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_http_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/post'
-        r = post(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True,
-        )
-        self.assertEqual(r.code, 200)
-        r = post(url, data=body, format='json', client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/put'
-        auth = dict(username='test', password='test')
-        r = put(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(r.code, 200)
-        r = put(url, data=body, format='json', client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-
-class TestHL2HTTPSUnit(unittest.TestCase):
-
-    def test_https_delete(self):
-        from wire.http import delete
-        r = delete('https://httpbin.ep.io/delete', client='urllib2', test=True)
-        self.assertEqual(r.code, 204)
-
-    def test_https_get(self):
-        from wire.http import get
-        r = get('https://httpbin.ep.io/get', client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r.json
-        )
-
-    def test_https_head(self):
-        from wire.http import head
-        r = head('https://httpbin.ep.io/headable/', client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-
-    def test_https_options(self):
-        from wire.http import options
-        r = options('https://httpbin.ep.io/option', client='urllib2', test=True)
-        self.assertEqual(r.code, 200, r.status)
-
-    def test_http_post(self):
-        from wire.http import post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = post(
-            'https://httpbin.ep.io/post',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True,
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-    def test_http_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = put(
-            'https://httpbin.ep.io/put',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(r.code, 201, r.status)
-
-
-class TestHL2HTTPSAuthUnit(unittest.TestCase):
-
-    def test_auth_https_delete(self):
-        from wire.http import delete
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/delete'
-        r = delete(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 204)
-        r = delete(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_get(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/get'
-        r = get(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        r = get(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_head(self):
-        from wire.http import get
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/headable/'
-        r = get(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        r = get(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_options(self):
-        from wire.http import options
-        auth = dict(username='test', password='test')
-        url = 'https://httpbin.ep.io/put'
-        r = options(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r.code, 200)
-        r = options(url, client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_post(self):
-        from wire.http import post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/post'
-        r = post(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(r.code, 201)
-        r = post(url, data=body, format='json', client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-    def test_auth_https_put(self):
-        from wire.http import put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'https://httpbin.ep.io/put'
-        auth = dict(username='test', password='test')
-        r = put(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(r.code, 201)
-        r = put(url, data=body, format='json', client='urllib2', test=True)
-        self.assertEqual(r.code, 401)
-
-
-###############################################################################
-# Fast HTTP
-###############################################################################
-
-class TestHL2FastHTTPUnit(unittest.TestCase):
-
-    maxDiff = None
-
-    def test_http_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete(
-            'http://httpbin.org/delete', client='urllib2', test=True
-        )
-        self.assertEqual(r, 200, r)
-
-    def test_http_get(self):
-        from wire.http import fast_get
-        r = fast_get('http://httpbin.org/get', client='urllib2', test=True)
-        self.assertDictEqual(
-            {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/post', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'},
-            r,
-        )
-
-    def test_http_head(self):
-        from wire.http import fast_head
-        r = fast_head('http://httpbin.org/head', client='urllib2', test=True)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_http_options(self):
-        from wire.http import fast_options
-        r = fast_options(
-            'http://httpbin.org/option', client='urllib2', test=True
-        )
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'http://httpbin.org/post',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(r, {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/post', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'}, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_put(
-            'http://httpbin.org/put',
-            data=body,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertDictEqual(
-            r,
-            {'files': {}, 'origin': '::ffff:76.27.119.104', 'form': {}, 'url': 'http://httpbin.org/put', 'args': {}, 'headers': {'Content-Length': '62', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'Accept': 'application/json', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': 'application/json'}, 'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"'}
-        )
-
-
-class TestHL2FastHTTPAuthUnit(unittest.TestCase):
-
-    maxDiff = None
-
-    def test_auth_http_delete(self):
-        from wire.http import fast_delete
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/delete'
-        r = fast_delete(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r, 200, r)
-        r = fast_delete(url, client='urllib2', test=True)
-        self.assertEqual(r, 401, r)
-
-    def test_auth_http_get(self):
-        from wire.http import fast_get
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/get'
-        r = fast_get(url, auth=auth, client='urllib2', test=True)
-        self.assertDictEqual(
-            {'origin': '::ffff:76.27.119.104', 'headers': {'Content-Length': '', 'Accept-Encoding': 'gzip, deflate', 'X-Forwarded-For': '::ffff:76.27.119.104', 'Host': 'httpbin.org', 'User-Agent': 'Python-httplib2/0.7.0 (gzip)', 'Connection': 'close', 'X-Forwarded-Protocol': '', 'Content-Type': ''}, 'args': {}, 'url': 'http://httpbin.org/get'}, r, r,
-        )
-        r = fast_get(url, client='urllib2', test=True)
-        self.assertEquals(r, 401, r)
-
-    def test_auth_http_head(self):
-        from wire.http import fast_head
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/headable/'
-        r = fast_head(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-        r = fast_head(url, client='urllib2', test=True)
-        self.assertEqual(r, 401)
-
-    def test_auth_http_options(self):
-        from wire.http import fast_options
-        auth = dict(username='test', password='test')
-        url = 'http://httpbin.org/option'
-        r = fast_options(url, auth=auth, client='urllib2', test=True)
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'])
-        r = fast_options(url, client='urllib2', test=True)
-        self.assertEqual(r, 401)
-
-    def test_http_post(self):
-        from wire.http import fast_post
-        auth = dict(username='test', password='test')
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/post'
-        r = fast_post(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertEqual(
-            {'args': {},
-  'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"',
-  'files': {},
-  'form': {},
-  'headers': {'Accept': 'application/json',
-              'Accept-Encoding': 'gzip, deflate',
-              'Connection': 'close',
-              'Content-Length': '62',
-              'Content-Type': 'application/json',
-              'Host': 'httpbin.org',
-              'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-              'X-Forwarded-For': '::ffff:76.27.119.104',
-              'X-Forwarded-Protocol': ''},
-  'origin': '::ffff:76.27.119.104',
-  'url': 'http://httpbin.org/post'}, r)
-        r = fast_post(
-            url, data=body, format='json', client='urllib2', test=True
-        )
-        self.assertEqual(r, 401, r)
-
-    def test_http_put(self):
-        from wire.http import fast_put
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        url = 'http://httpbin.org/put'
-        auth = dict(username='test', password='test')
-        r = fast_put(
-            url,
-            data=body,
-            auth=auth,
-            format='json',
-            client='urllib2',
-            test=True
-        )
-        self.assertDictEqual(
-            r,
-            {'args': {},
-  'data': '"{\\"json\\": \\"test\\", \\"verify\\": true, \\"array\\": [1, 2, 3]}"',
-  'files': {},
-  'form': {},
-  'headers': {'Accept': 'application/json',
-              'Accept-Encoding': 'gzip, deflate',
-              'Connection': 'close',
-              'Content-Length': '62',
-              'Content-Type': 'application/json',
-              'Host': 'httpbin.org',
-              'User-Agent': 'Python-httplib2/0.7.0 (gzip)',
-              'X-Forwarded-For': '::ffff:76.27.119.104',
-              'X-Forwarded-Protocol': ''},
-  'origin': '::ffff:76.27.119.104',
-  'url': 'http://httpbin.org/put'})
-        r = fast_put(url, data=body, format='json', client='urllib2', test=True)
-        self.assertEqual(r, 401)
-
-
-class TestHL2FastHTTPSUnit(unittest.TestCase):
-
-    def test_https_delete(self):
-        from wire.http import fast_delete
-        r = fast_delete(
-            'https://httpbin.ep.io/delete', client='urllib2', test=True
-        )
-        self.assertEqual(r, 204)
-
-    def test_https_get(self):
-        from wire.http import fast_get
-        r = fast_get('https://httpbin.ep.io/get', client='urllib2', test=True)
-        self.assertDictEqual(
-            dict(json="test", verify=True, array=[1, 2, 3]), r, r
-        )
-
-    def test_https_head(self):
-        from wire.http import fast_head
-        r = fast_head(
-            'https://httpbin.ep.io/headable/', client='urllib2', test=True
-        )
-        self.assertEqual(
-            r,
-            {'date': datetime(2011, 3, 15, 18, 10),
-            'content-type': 'application/json', 'server': 'Fake Server 1.0'},
-            r
-        )
-
-    def test_https_options(self):
-        from wire.http import fast_options
-        r = fast_options(
-            'https://httpbin.ep.io/option', client='urllib2', test=True
-        )
-        self.assertEqual(r, ['GET', 'OPTIONS', 'POST'], r)
-
-    def test_https_post(self):
-        from wire.http import fast_post
-        body = '{"json": "test", "verify": true, "array": [1, 2, 3]}'
-        r = fast_post(
-            'https://httpbin.ep.io/post',