def get_http_info_with_retriever(self, request, retriever): """ Exact method for getting http_info but with form data work around. """ urlparts = urlparse.urlsplit(request.url) try: data = retriever(request) except Exception: data = {} return { 'url': '{0}://{1}{2}'.format(urlparts.scheme, urlparts.netloc, urlparts.path), 'query_string': urlparts.query, 'method': request.method, 'data': data, 'cookies': request.cookies, 'headers': request.headers, 'env': { 'REMOTE_ADDR': request.remote_addr, } }
def get_data_from_request(request): urlparts = urlparse.urlsplit(request.url) try: form_dict = request.forms.dict # we only are about the most recent one formdata = dict([(k, form_dict[k][-1]) for k in form_dict]) except Exception: formdata = {} data = { 'request': { 'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path), 'query_string': urlparts.query, 'method': request.method, 'data': formdata, 'headers': dict(get_headers(request.environ)), 'env': dict(get_environ(request.environ)), } } return data
def get_http_info_with_retriever(self, request, retriever=None): """ Exact method for getting http_info but with form data work around. """ if retriever is None: retriever = self.get_form_data urlparts = urlparse.urlsplit(request.url) try: data = retriever(request) except ClientDisconnected: data = {} return { 'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path), 'query_string': urlparts.query, 'method': request.method, 'data': data, 'headers': dict(get_headers(request.environ)), 'env': dict(get_environ(request.environ)), }
def get_data_from_request(request): urlparts = urlparse.urlsplit(request.url) try: form_dict = request.forms.dict # we only are about the most recent one formdata = dict([(k, form_dict[k][-1]) for k in form_dict]) except Exception: formdata = {} data = { "request": { "url": "%s://%s%s" % (urlparts.scheme, urlparts.netloc, urlparts.path), "query_string": urlparts.query, "method": request.method, "data": formdata, "headers": dict(get_headers(request.environ)), "env": dict(get_environ(request.environ)), } } return data
def get_http_info_with_retriever(self, request, retriever): """ Exact method for getting http_info but with form data work around. """ urlparts = urlparse.urlsplit(request.url) try: data = retriever(request) except Exception: data = {} return { 'url': '{0}://{1}{2}'.format( urlparts.scheme, urlparts.netloc, urlparts.path), 'query_string': urlparts.query, 'method': request.method, 'data': data, 'cookies': request.cookies, 'headers': request.headers, 'env': { 'REMOTE_ADDR': request.remote_addr, } }