httprequest

Getting the options in a http request status 300

Getting the options in a http request status 300 Question: I read that when I get this error I should specify better the url. I assume that I should specify between two displayed or accessible options. How can I do that? In urllib or its tutorial I couldn’t find anything. My assumption is true? Can …

Total answers: 2

CherryPy: How to process a request before it has reached the application method?

CherryPy: How to process a request before it has reached the application method? Question: I want to be able to catch the arguments of the methods of my CherryPy application before the method itself. But I’m not sure if there is a way to do it in CherryPy or with standard python. It should look …

Total answers: 2

Python Request Post with param data

Python Request Post with param data Question: This is the raw request for an API call: POST http://192.168.3.45:8080/api/v2/event/log?sessionKey=b299d17b896417a7b18f46544d40adb734240cc2&format=json HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Content-Length: 86 Host: 192.168.3.45:8080 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) {"eventType":"AAS_PORTAL_START","data":{"uid":"hfe3hf45huf33545","aid":"1","vid":"1"}} This request returns a success (2xx) response. Now I am trying to post this request using requests: import requests headers = …

Total answers: 3

A good way to get the charset/encoding of an HTTP response in Python

A good way to get the charset/encoding of an HTTP response in Python Question: Looking for an easy way to get the charset/encoding information of an HTTP response using Python urllib2, or any other Python library. >>> url = ‘http://some.url.value’ >>> request = urllib2.Request(url) >>> conn = urllib2.urlopen(request) >>> response_encoding = ? I know that …

Total answers: 6

Python Requests requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol

Python Requests requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol Question: I’m on Ubuntu 12.10 with OpenSSL 1.0.1c, python 2.7.3, Requests 1.0.3 and 1.0.4 (tried both), and when attempting to connect to the website in the url variable with the following code. def SendInitialRequest(xmlmessage, redirecturl): url = ‘https://centineltest.cardinalcommerce.com/maps/txns.asp’ payload = ‘cmpi_msg=’ + ET.tostring(xmlmessage) …

Total answers: 10

How to do a HTTP DELETE request with Requests library

How to do a HTTP DELETE request with Requests library Question: I’m using the requests package for interacting with the toggl.com API. I can perform GET and POST requests: payload = {‘some’:’data’} headers = {‘content-type’: ‘application/json’} url = “https://www.toggl.com/api/v6/” + data_description + “.json” response = requests.post(url, data=json.dumps(payload), headers=headers,auth=HTTPBasicAuth(toggl_token, ‘api_token’)) but i cant seem to find …

Total answers: 2

Asynchronous Requests with Python requests

Asynchronous Requests with Python requests Question: I tried the sample provided within the documentation of the requests library for python. With async.map(rs), I get the response codes, but I want to get the content of each page requested. This, for example, does not work: out = async.map(rs) print out[0].content Asked By: trbck || Source Answers: …

Total answers: 15

Proxies with Python 'Requests' module

Proxies with Python 'Requests' module Question: Just a short, simple one about the excellent Requests module for Python. I can’t seem to find in the documentation what the variable ‘proxies’ should contain. When I send it a dict with a standard "IP:PORT" value it rejected it asking for 2 values. So, I guess (because this …

Total answers: 12

How can I get all the request headers in Django?

How can I get all the request headers in Django? Question: I need to get all the Django request headers. From what I’ve read, Django simply dumps everything into the request.META variable along with a lot of other data. What would be the best way to get all the headers that the client sent to …

Total answers: 10

how to loop through httprequest post variables in python

how to loop through httprequest post variables in python Question: How can you loop through the HttpRequest post variables in Django? I have for k,v in request.POST: print k,v which is not working properly. Thanks! Asked By: icn || Source Answers: request.POST is a dictionary-like object containing all given HTTP POST parameters. When you loop …

Total answers: 1