def posthandler(*args, **kwargs): request = kwargs['RequestURI'] response = yield httppost('localhost', port, '/path', body, headers={'Content-Type': 'text/plain'} ) yield response done.append(response)
def _httppost(self, **kwargs): if self._synchronous: req = Request("http://%(host)s:%(port)s%(request)s" % kwargs, kwargs['body']) req.add_header('User-Agent', kwargs['headers']['User-Agent']) response = urlopen(req) raise StopIteration((str(response.getcode()), response.read())) response = yield httppost(**kwargs) raise StopIteration((response.split(CRLF * 2)))
def _httppost(self, **kwargs): if self._synchronous: req = Request("http://%(host)s:%(port)s%(request)s" % kwargs, kwargs['body']) req.add_header('User-Agent', kwargs['headers']['User-Agent']) response = urlopen(req) return [dict(StatusCode=str(response.getcode())), response.read()] response = yield httppost(**kwargs) header, body = parseResponse(response) return [header, body]
def posthandler(*args, **kwargs): response = yield httppost('localhost', port, '/path', body) yield response responses.append(response)
def _httppost(self, **kwargs): return httppost(**kwargs)