twisted.web.http_headers.Headers

Here are the examples of the python api twisted.web.http_headers.Headers taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

Example 1

Project: vumi
Source File: transport_stubs.py
View license
    @classmethod
    def req_POST(cls, url, params, headers=None):
        agent = Agent(reactor)
        hdrs = {
            'User-Agent': ['Vumi Vas2Net Faker'],
            'Content-Type': ['application/x-www-form-urlencoded'],
            }
        if headers:
            hdrs.update(headers)
        d = agent.request('POST', url, Headers(hdrs),
                          StringProducer(urlencode(params)))
        return d.addCallback(cls.handle)

Example 2

Project: vumi
Source File: utils.py
View license
def mkheaders(headers):
    """
    Turn a dict of HTTP headers into an instance of Headers.

    Twisted expects a list of values, not a single value. We should
    support both.
    """
    raw_headers = {}
    for k, v in headers.iteritems():
        if isinstance(v, basestring):
            v = [v]
        raw_headers[k] = v
    return Headers(raw_headers)

Example 3

Project: vumi-go
Source File: test_vumi_app.py
View license
    @inlineCallbacks
    def test_invalid_auth(self):
        url = '%s/%s/messages.json' % (self.url, self.conversation.key)

        queue = DeferredQueue()

        headers = Headers({
            'Authorization': ['Basic %s' % (base64.b64encode('foo:bar'),)],
        })

        receiver = self.client.stream(
            TransportUserMessage, queue.put, queue.put, url, headers)
        response = yield receiver.get_response()
        self.assertEqual(response.code, http.UNAUTHORIZED)
        self.assertEqual(response.headers.getRawHeaders('www-authenticate'), [
            'basic realm="Conversation Realm"'])

Example 4

Project: vumi-go
Source File: test_vumi_app.py
View license
    @inlineCallbacks
    def test_backlog_on_connect(self):
        for i in range(10):
            yield self.app_helper.make_dispatch_inbound(
                'in %s' % (i,), message_id=str(i), conv=self.conversation)

        queue = DeferredQueue()
        url = '%s/%s/messages.json' % (self.url, self.conversation.key)
        receiver = self.client.stream(
            TransportUserMessage, queue.put, queue.put, url,
            Headers(self.auth_headers))

        for i in range(10):
            received = yield queue.get()
            self.assertEqual(received['message_id'], str(i))

        receiver.disconnect()

Example 5

Project: mamba-framework
Source File: herokuservice.py
View license
    def ping(self):
        """Ping our application to not allow heroku idle it
        """

        if config.Application().heroku_url is None:
            return

        heroku_url = config.Application().heroku_url
        log.msg('Heroku Awakening: Pinging {}'.format(heroku_url))
        return Agent(reactor).request(
            'GET', '{url}/_mamba_pong'.format(url=str(heroku_url)),
            Headers({'User-Agent': ['Mamba Heroku Web Client']}),
            None
        )

Example 6

Project: mamba-framework
Source File: test_controller.py
View license
    def __init__(self, postpath, params, session=None):
        self.content = StringIO()
        self.content.write(urllib.urlencode(params))
        self.content.seek(0, 0)
        self.requestHeaders = Headers()

        DummyRequest.__init__(self, postpath, session)

Example 7

Project: mamba-framework
Source File: test_web.py
View license
def request_generator(url, method='GET', content=True, headers=True):
    request = DummyRequest(url)
    request.method = method
    if content:
        request.content = StringIO()
    if headers:
        request.requestHeaders = Headers()

    return request

Example 8

Project: restkin
Source File: scribe.py
View license
    def log(self, category, message):
        if category != self.category:
            log.msg(format=("Unknown category: %(category)s "
                            "expected %(expected_category)"),
                    category=category,
                    expected_category=self.category)

        d = self._agent.request(
            'POST', self._restkin_url,
            Headers({'Content-Type': ['application/json']}),
            FileBodyProducer(StringIO(message)))

        d.addCallback(self._log_success)
        d.addErrback(log.err, "Unhandled error while posting to RESTKin")

Example 9

Project: rollingpin
Source File: harold.py
View license
    def make_request(self, path, data):
        base_url = urlparse.urlparse(self.base_url)
        path = posixpath.join(base_url.path, "harold", path)
        url = urlparse.urlunparse((
            base_url.scheme,
            base_url.netloc,
            path,
            None,
            None,
            None
        ))

        body_producer = FormEncodedBodyProducer(data)
        headers = Headers({
            "User-Agent": ["rollingpin"],
            "Content-Type": ["application/x-www-form-urlencoded"],
            "X-Hub-Signature": ["sha1=" + body_producer.hash(self.secret)],
        })
        return self.agent.request("POST", url, headers, body_producer)

Example 10

Project: pinder
Source File: streaming.py
View license
def start(username, password, room_id, callback, errback, start_reactor=False):
    auth_header = 'Basic ' + base64.b64encode("%s:%s" % (username, password)).strip()
    url = 'https://streaming.campfirenow.com/room/%s/live.json' % room_id
    headers = Headers({
        'User-Agent': [USER_AGENT],
        'Authorization': [auth_header]})

    # issue the request
    agent = Agent(reactor)
    d = agent.request('GET', url, headers, None)
    d.addCallback(_get_response, callback, errback)
    d.addBoth(_shutdown, errback)
    if start_reactor:
      reactor.run()

Example 11

Project: scrapy
Source File: client.py
View license
    def request(self, method, uri, headers=None, bodyProducer=None):
        """
        Send a client request which declares supporting compressed content.

        @see: L{Agent.request}.
        """
        if headers is None:
            headers = Headers()
        else:
            headers = headers.copy()
        headers.addRawHeader('accept-encoding', self._supported)
        deferred = self._agent.request(method, uri, headers, bodyProducer)
        return deferred.addCallback(self._handleResponse)

Example 12

Project: smap
Source File: client.py
View license
    def connect(self):
        """Subscribe and start receiving data.  No callbacks will be called
before this connecting.
        """
        self.closing = False
        url = self.url + '/republish?' + \
            urllib.urlencode(make_qdict(self.key, self.private), 
                             doseq=True)

        if not self.restrict:
            d = self.agent.request('GET', url, Headers(), None)
        else:
            d = self.agent.request('POST', url, Headers(), 
                                   FileBodyProducer(StringIO(str(self.restrict))))
        d.addCallback(self.__request)
        d.addErrback(self._connect_failed)

Example 13

Project: tryfer
Source File: test_http.py
View license
    def test_delgates_to_agent(self):
        agent = TracingAgent(self.agent, self.trace)

        agent.request('GET', 'https://google.com')

        self.agent.request.assert_called_with(
            'GET', 'https://google.com',
            Headers({'X-B3-TraceId': ['0000000000000001'],
                     'X-B3-SpanId': ['0000000000000003'],
                     'X-B3-ParentSpanId': ['0000000000000002']}),
            None)

Example 14

Project: tryfer
Source File: test_http.py
View license
    def setUp(self):
        self.wrapped = mock.Mock(Resource)
        self.resource = TracingWrapperResource(self.wrapped)

        self.request = mock.Mock(Request)
        self.request.method = 'GET'
        self.request.requestHeaders = mock.Mock(wraps=Headers({}))
        self.request.getHost.return_value.host = '127.0.0.1'
        self.request.getHost.return_value.port = 8080

Example 15

Project: tryfer
Source File: test_tracers.py
View license
    def test_posts_immediately(self):
        self.trace.record(Annotation.client_send(1))

        self.assertEqual(self.agent.request.call_count, 1)

        args = self.agent.request.mock_calls[0][1]
        self.assertEqual(('POST', 'http://trace.it', Headers({})), args[:3])

        bodyProducer = args[3]

        return self.assertBodyEquals(
            bodyProducer,
            [{'trace_id': '0000000000000001',
              'span_id': '0000000000000002',
              'name': 'test',
              'annotations': [
                  {'type': 'timestamp', 'value': 1, 'key': 'cs'}
              ]}])

Example 16

Project: tryfer
Source File: tracers.py
View license
    def record(self, traces):
        producer = FileBodyProducer(StringIO(json_formatter(traces)))

        d = self._agent.request('POST', self._trace_url, Headers({}), producer)
        d.addErrback(
            log.err,
            "Error sending trace to: {0}".format(self._trace_url))

Example 17

Project: treq
Source File: auth.py
View license
def add_basic_auth(agent, username, password):
    creds = base64.b64encode(
        '{0}:{1}'.format(username, password).encode('ascii'))
    return _RequestHeaderSettingAgent(
        agent,
        Headers({b'Authorization': [b'Basic ' + creds]}))

Example 18

Project: treq
Source File: test_auth.py
View license
    def test_sets_headers(self):
        agent = _RequestHeaderSettingAgent(
            self.agent,
            Headers({b'X-Test-Header': [b'Test-Header-Value']}))

        agent.request('method', 'uri')

        self.agent.request.assert_called_once_with(
            'method', 'uri',
            headers=Headers({b'X-Test-Header': [b'Test-Header-Value']}),
            bodyProducer=None
        )

Example 19

Project: treq
Source File: test_auth.py
View license
    def test_overrides_per_request_headers(self):
        agent = _RequestHeaderSettingAgent(
            self.agent,
            Headers({b'X-Test-Header': [b'Test-Header-Value']})
        )

        agent.request(
            'method', 'uri',
            Headers({b'X-Test-Header': [b'Unwanted-Value']})
        )

        self.agent.request.assert_called_once_with(
            'method', 'uri',
            headers=Headers({b'X-Test-Header': [b'Test-Header-Value']}),
            bodyProducer=None
        )

Example 20

Project: treq
Source File: test_auth.py
View license
    def test_add_basic_auth(self):
        agent = mock.Mock()

        add_auth(agent, ('username', 'password'))

        self._RequestHeaderSettingAgent.assert_called_once_with(
            agent,
            Headers({b'authorization': [b'Basic dXNlcm5hbWU6cGFzc3dvcmQ=']})
        )

Example 21

Project: treq
Source File: test_auth.py
View license
    def test_add_basic_auth_huge(self):
        agent = mock.Mock()
        pwd = ('verylongpasswordthatextendsbeyondthepointwheremultiplel'
               'inesaregenerated')
        auth = (b'Basic dXNlcm5hbWU6dmVyeWxvbmdwYXNzd29yZHRoYXRleHRlbmRzY'
                b'mV5b25kdGhlcG9pbnR3aGVyZW11bHRpcGxlbGluZXNhcmVnZW5lcmF0ZWQ=')
        add_auth(agent, ('username', pwd))

        self._RequestHeaderSettingAgent.assert_called_once_with(
            agent,
            Headers({b'authorization': [auth]}))

Example 22

Project: treq
Source File: test_client.py
View license
    def test_request_query_params(self):
        self.client.request('GET', 'http://example.com/',
                            params={'foo': ['bar']})

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/?foo=bar',
            Headers({b'accept-encoding': [b'gzip']}), None)

Example 23

Project: treq
Source File: test_client.py
View license
    def test_request_tuple_query_values(self):
        self.client.request('GET', 'http://example.com/',
                            params={'foo': ('bar',)})

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/?foo=bar',
            Headers({b'accept-encoding': [b'gzip']}), None)

Example 24

Project: treq
Source File: test_client.py
View license
    def test_request_merge_query_params(self):
        self.client.request('GET', 'http://example.com/?baz=bax',
                            params={'foo': ['bar', 'baz']})

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/?baz=bax&foo=bar&foo=baz',
            Headers({b'accept-encoding': [b'gzip']}), None)

Example 25

Project: treq
Source File: test_client.py
View license
    def test_request_merge_tuple_query_params(self):
        self.client.request('GET', 'http://example.com/?baz=bax',
                            params=[('foo', 'bar')])

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/?baz=bax&foo=bar',
            Headers({b'accept-encoding': [b'gzip']}), None)

Example 26

Project: treq
Source File: test_client.py
View license
    def test_request_dict_single_value_query_params(self):
        self.client.request('GET', 'http://example.com/',
                            params={'foo': 'bar'})

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/?foo=bar',
            Headers({b'accept-encoding': [b'gzip']}), None)

Example 27

Project: treq
Source File: test_client.py
View license
    def test_request_data_dict(self):
        self.client.request('POST', 'http://example.com/',
                            data={'foo': ['bar', 'baz']})

        self.agent.request.assert_called_once_with(
            b'POST', b'http://example.com/',
            Headers({b'Content-Type': [b'application/x-www-form-urlencoded'],
                     b'accept-encoding': [b'gzip']}),
            self.FileBodyProducer.return_value)

        self.assertBody(b'foo=bar&foo=baz')

Example 28

Project: treq
Source File: test_client.py
View license
    def test_request_data_single_dict(self):
        self.client.request('POST', 'http://example.com/',
                            data={'foo': 'bar'})

        self.agent.request.assert_called_once_with(
            b'POST', b'http://example.com/',
            Headers({b'Content-Type': [b'application/x-www-form-urlencoded'],
                     b'accept-encoding': [b'gzip']}),
            self.FileBodyProducer.return_value)

        self.assertBody(b'foo=bar')

Example 29

Project: treq
Source File: test_client.py
View license
    def test_request_data_tuple(self):
        self.client.request('POST', 'http://example.com/',
                            data=[('foo', 'bar')])

        self.agent.request.assert_called_once_with(
            b'POST', b'http://example.com/',
            Headers({b'Content-Type': [b'application/x-www-form-urlencoded'],
                     b'accept-encoding': [b'gzip']}),
            self.FileBodyProducer.return_value)

        self.assertBody(b'foo=bar')

Example 30

Project: treq
Source File: test_client.py
View license
    def test_request_data_file(self):
        temp_fn = self.mktemp()

        with open(temp_fn, "wb") as temp_file:
            temp_file.write(b'hello')

        self.client.request('POST', 'http://example.com/',
                            data=open(temp_fn, 'rb'))

        self.agent.request.assert_called_once_with(
            b'POST', b'http://example.com/',
            Headers({b'accept-encoding': [b'gzip']}),
            self.FileBodyProducer.return_value)

        self.assertBody(b'hello')

Example 31

Project: treq
Source File: test_client.py
View license
    @mock.patch('treq.client.uuid.uuid4', mock.Mock(return_value="heyDavid"))
    def test_request_no_name_attachment(self):

        self.client.request(
            'POST', 'http://example.com/', files={"name": BytesIO(b"hello")})

        self.agent.request.assert_called_once_with(
            b'POST', b'http://example.com/',
            Headers({
                b'accept-encoding': [b'gzip'],
                b'Content-Type': [b'multipart/form-data; boundary=heyDavid']}),
            self.MultiPartProducer.return_value)

        FP = self.FileBodyProducer.return_value
        self.assertEqual(
            mock.call(
                [('name', (None, 'application/octet-stream', FP))],
                boundary=b'heyDavid'),
            self.MultiPartProducer.call_args)

Example 32

Project: treq
Source File: test_client.py
View license
    def test_request_dict_headers(self):
        self.client.request('GET', 'http://example.com/', headers={
            'User-Agent': 'treq/0.1dev',
            'Accept': ['application/json', 'text/plain']
        })

        self.agent.request.assert_called_once_with(
            b'GET', b'http://example.com/',
            Headers({b'User-Agent': [b'treq/0.1dev'],
                     b'accept-encoding': [b'gzip'],
                     b'Accept': [b'application/json', b'text/plain']}),
            None)

Example 33

Project: treq
Source File: test_client.py
View license
    @with_clock
    def test_request_timeout_cancelled(self, clock):
        """
        Verify timeout is cancelled if a response is received before
        timeout period elapses.
        """
        self.agent.request.return_value = d = Deferred()
        self.client.request('GET', 'http://example.com', timeout=2)

        # simulate a response
        d.callback(mock.Mock(code=200, headers=Headers({})))

        # now advance the clock but since we already got a result,
        # a cancellation timer should have been cancelled
        clock.advance(3)

        self.successResultOf(d)

Example 34

Project: treq
Source File: test_client.py
View license
    def test_response_is_buffered(self):
        response = mock.Mock(deliverBody=mock.Mock(),
                             headers=Headers({}))

        self.agent.request.return_value = succeed(response)

        d = self.client.get('http://www.example.com')

        result = self.successResultOf(d)

        protocol = mock.Mock(Protocol)
        result.deliverBody(protocol)
        self.assertEqual(response.deliverBody.call_count, 1)

        result.deliverBody(protocol)
        self.assertEqual(response.deliverBody.call_count, 1)

Example 35

Project: treq
Source File: test_client.py
View license
    def test_response_buffering_is_disabled_with_unbufferred_arg(self):
        response = mock.Mock(headers=Headers({}))

        self.agent.request.return_value = succeed(response)

        d = self.client.get('http://www.example.com', unbuffered=True)

        # YOLO public attribute.
        self.assertEqual(self.successResultOf(d).original, response)

Example 36

Project: treq
Source File: test_client.py
View license
    def test_request_browser_like_redirects(self):
        response = mock.Mock(code=302, headers=Headers({'Location': ['/']}))

        self.agent.request.return_value = succeed(response)

        raw = mock.Mock(return_value=[])
        final_resp = mock.Mock(code=200, headers=mock.Mock(getRawHeaders=raw))
        with mock.patch('twisted.web.client.RedirectAgent._handleRedirect',
                        return_value=final_resp):
            d = self.client.post('http://www.google.com',
                                 browser_like_redirects=True,
                                 unbuffered=True)

        self.assertEqual(self.successResultOf(d).original, final_resp)

Example 37

Project: treq
Source File: test_content.py
View license
    def test_json_content(self):
        self.response.headers = Headers()
        d = json_content(self.response)

        self.protocol.dataReceived(b'{"msg":"hello!"}')
        self.protocol.connectionLost(Failure(ResponseDone()))

        self.assertEqual(self.successResultOf(d), {"msg": "hello!"})

Example 38

Project: treq
Source File: test_content.py
View license
    def test_json_content_unicode(self):
        """
        When Unicode JSON content is received, the JSON text should be
        correctly decoded.
        RFC7159 (8.1): "JSON text SHALL be encoded in UTF-8, UTF-16, or UTF-32.
        The default encoding is UTF-8"
        """
        self.response.headers = Headers()
        d = json_content(self.response)

        self.protocol.dataReceived(u'{"msg":"hëlló!"}'.encode('utf-8'))
        self.protocol.connectionLost(Failure(ResponseDone()))

        self.assertEqual(self.successResultOf(d), {u'msg': u'hëlló!'})

Example 39

Project: treq
Source File: test_content.py
View license
    def test_text_content(self):
        self.response.headers = Headers(
            {b'Content-Type': [b'text/plain; charset=utf-8']})

        d = text_content(self.response)

        self.protocol.dataReceived(b'\xe2\x98\x83')
        self.protocol.connectionLost(Failure(ResponseDone()))

        self.assertEqual(self.successResultOf(d), u'\u2603')

Example 40

Project: treq
Source File: test_content.py
View license
    def test_text_content_default_encoding_no_param(self):
        self.response.headers = Headers(
            {b'Content-Type': [b'text/plain']})

        d = text_content(self.response)

        self.protocol.dataReceived(b'\xa1')
        self.protocol.connectionLost(Failure(ResponseDone()))

        self.assertEqual(self.successResultOf(d), u'\xa1')

Example 41

Project: treq
Source File: test_content.py
View license
    def test_text_content_default_encoding_no_header(self):
        self.response.headers = Headers()

        d = text_content(self.response)

        self.protocol.dataReceived(b'\xa1')
        self.protocol.connectionLost(Failure(ResponseDone()))

        self.assertEqual(self.successResultOf(d), u'\xa1')

Example 42

Project: hls-proxy
Source File: hlsproxy.py
View license
    def refreshPlaylist(self):
        print "Getting playlist from ", self.srvPlaylistUrl
        d = self.reqQ.request('GET', self.srvPlaylistUrl,
            Headers(self.httpHeaders()),
            None)
        d.addCallback(self.cbRequest)
        d.addErrback(self.onGetPlaylistError)
        return d

Example 43

Project: hls-proxy
Source File: hlsproxy.py
View license
    def requestFragment(self, item):
        print "Getting fragment from ", item.absoluteUrl
        d = self.reqQ.request('GET', item.absoluteUrl,
            Headers(self.httpHeaders()),
            None)
        thiz = self
        d.addCallback(lambda r: thiz.cbFragment(r, item))
        d.addErrback(lambda e: e.printTraceback())
        return d

Example 44

Project: hls-proxy
Source File: hlsproxy.py
View license
    def requestResource(self, url, localFilename):
        print "Getting resource from ", url, " -> ", localFilename
        d = self.reqQ.request('GET', url, Headers(self.httpHeaders()), None)
        thiz = self
        d.addCallback(lambda r: thiz.cbRequestResource(r, localFilename))
        d.addErrback(lambda e: e.printTraceback())
        return d

Example 45

Project: petmail
Source File: eventsource.py
View license
    def start(self):
        assert not self.started, "single-use"
        self.started = True
        a = Agent(reactor)
        d = a.request("GET", self.url,
                      Headers({"accept": ["text/event-stream"]}))
        d.addCallback(self._connected)
        return d

Example 46

Project: ants
Source File: client.py
View license
    def request(self, method, uri, headers=None, bodyProducer=None):
        """
        Send a client request which declares supporting compressed content.

        @see: L{Agent.request}.
        """
        if headers is None:
            headers = Headers()
        else:
            headers = headers.copy()
        headers.addRawHeader('accept-encoding', self._supported)
        deferred = self._agent.request(method, uri, headers, bodyProducer)
        return deferred.addCallback(self._handleResponse)

Example 47

Project: tensor
Source File: riak.py
View license
    @defer.inlineCallbacks
    def _get_stats_from_node(self):
        agent = Agent(reactor)

        url = self.config.get('url', 'http://%s:8098/stats' % self.hostname)
        ua = self.config.get('useragent', 'Tensor Riak stats checker')

        headers = Headers({'User-Agent': [ua]})
        request = yield agent.request('GET', url, headers)

        if request.length:
            d = defer.Deferred()
            request.deliverBody(BodyReceiver(d))
            b = yield d
            body = b.read()
        else:
            body = ""

        defer.returnValue(json.loads(body))

Example 48

Project: PSO2Proxy
Source File: EQ_Notice.py
View license
def CheckupURL():
    HTTPHeader0 = Headers({'User-Agent': ['PSO2Proxy']})
    load_eqJP_names()  # Reload file
    for shipNum in config.globalConfig.get_key('enabledShips'):
        if eqnotice_config.key_exists(str(shipNum)):
            eq_URL = eqnotice_config.get_key(str(shipNum))
        else:
            eq_URL = None
        if eq_URL:
            HTTPHeaderX = HTTPHeader0.copy()
            if ETag_Headers[shipNum]:
                HTTPHeaderX.addRawHeader('If-None-Match', ETag_Headers[shipNum])
            if Modified_Headers[shipNum]:
                HTTPHeaderX.addRawHeader('If-Modified-Since', Modified_Headers[shipNum])
            EQ0 = agent.request('GET', eq_URL, HTTPHeaderX)
            EQ0.addCallback(EQResponse, shipNum)
            EQ0.addErrback(log.err)

Example 49

Project: PSO2Proxy
Source File: EQ_Alert.py
View license
def CheckupURL():
    HTTPHeader0 = Headers({'User-Agent': ['PSO2Proxy']}) #We need to send a User-Agent
    if eqalert_config.key_exists('api'):
        eq_URL = eqalert_config.get_key('api')
    else:
        eq_URL = None
    if eq_URL:
        HTTPHeaderX = HTTPHeader0.copy()
        if ETag_Header:
            HTTPHeaderX.addRawHeader('If-None-Match', ETag_Header)
        if Modified_Header:
            HTTPHeaderX.addRawHeader('If-Modified-Since', Modified_Header)
        EQ0 = agent.request('GET', eq_URL, HTTPHeaderX)
        EQ0.addCallback(EQResponse)
        EQ0.addErrback(log.err)

Example 50

Project: deluge
Source File: test_web_api.py
View license
    @defer.inlineCallbacks
    def test_invalid_json(self):
        """
        If json_api._send_response does not return server.NOT_DONE_YET
        this error is thrown when json is invalid:
        exceptions.RuntimeError: Request.write called on a request after Request.finish was called.

        """
        agent = Agent(reactor)
        bad_body = '{ method": "auth.login" }'
        d = yield agent.request(
            'POST',
            'http://127.0.0.1:%s/json' % self.webserver_listen_port,
            Headers({'User-Agent': ['Twisted Web Client Example'],
                     'Content-Type': ['application/json']}),
            FileBodyProducer(StringIO(bad_body)))
        yield d