Questions tagged [http-request]

HTTP Request is a message within a request/response sequence, according to HTTP specification. May also refer an HttpRequest class in software frameworks and libraries that automates relevant functionality

From W3C specification:

A request message from a client to a server includes, within the first line of that message, the method to be applied to the resource, the identifier of the resource, and the protocol version in use.

    Request       = Request-Line              ;
                    *(( general-header        ;
                     | request-header         ;
                     | entity-header ) CRLF)  ;
                    CRLF
                    [ message-body ]          ;

See also:

355 questions
322
votes
4 answers

Using headers with the Python requests library's get method

So I recently stumbled upon this great library for handling HTTP requests in Python; found here http://docs.python-requests.org/en/latest/index.html. I love working with it, but I can't figure out how to add headers to my get requests. Help?
Breedly
  • 12,838
  • 13
  • 59
  • 83
186
votes
3 answers

How to send cookies in a post request with the Python Requests library?

I'm trying to use the Requests library to send cookies with a post request, but I'm not sure how to actually set up the cookies based on its documentation. The script is for use on Wikipedia, and the cookie(s) that need to be sent are of this…
Ricardo Altamirano
  • 14,650
  • 21
  • 72
  • 105
157
votes
3 answers

How to extract HTTP response body from a Python requests call?

I'm using the Python requests library. I'm trying to figure out how to extract the actual HTML body from a response. The code looks a bit like this: r = requests.get(...) print r.content This should indeed print lots of content, but instead prints…
Stephen Gross
  • 5,274
  • 12
  • 41
  • 59
92
votes
3 answers

How to set the allowed url length for a nginx request (error code: 414, uri too large)

I am using Nginx in front of 10 mongrels. When I make a request with size larger then 2900 I get back an: error code 414: uri too large Does anyone know the setting in the nginx configuration file which determines the allowed uri length ?
Prakash Raman
  • 13,319
  • 27
  • 82
  • 132
91
votes
4 answers

When should one use CONNECT and GET HTTP methods at HTTP Proxy Server?

I'm building a WebClient library. Now I'm implementing a proxy feature, so I am making some research and I saw some code using the CONNECT method to request a URL. But checking it within my web browser, it doesn't use the CONNECT method but calls…
Alexsandro
  • 1,191
  • 1
  • 14
  • 22
67
votes
5 answers

Python requests exception handling

How to handle exceptions with python library requests? For example how to check is PC connected to internet? When I try try: requests.get('http://www.google.com') except ConnectionError: # handle the exception it gives me error name…
user1159798
53
votes
1 answer

HTTP status code for unaccepted Content-Type in request

For certain resources, my RESTful server only accepts PUT and POST requests with JSON objects as the content body, thus requiring a Content-Type of application/json instead of application/x-www-form-urlencoded or multipart/form-data or anything…
Jordan
  • 4,510
  • 7
  • 34
  • 42
49
votes
2 answers

Sending multipart/mixed content with Postman Chrome extension

I'm struggling with creating POST multipart/mixed request with Postman Chrome extension Here is my curl request what works nice curl -H "Content-Type: multipart/mixed" -F "metadata=@simple_json.json; type=application/json " -F "content=@1.jpg;…
pbaranski
  • 22,778
  • 19
  • 100
  • 117
42
votes
7 answers

How secure is HTTP_ORIGIN?

I want to find out whether an incoming HTTP_REQUEST call from a third party website is coming from the list of domains that I defined. I know that HTTP_REFERER can be used to find out where the third party domain is, but it is not secure enough.…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
35
votes
7 answers

Node.js: how to limit the HTTP request size and upload file size?

I'm using Node.js and express. I would like to limit the HTTP request size. Let's say, if someone sends me a HTTP request more than 2 MB then I stop the request right away. I looked at the code and I think if I change the core, I can do it.…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
25
votes
3 answers

AttributeError: 'str' object has no attribute 'items'

In the following code: #!/usr/local/bin/python import json APPLICATION_NAME = 'cc9226315643df89-36bf02429075329d0ba36748360d050c' HEADERS1 = json.dumps(dict(Destination = u"/api/af/latest/applications/%s/rulesets" % (APPLICATION_NAME))) print…
snrkl
  • 253
  • 1
  • 3
  • 4
23
votes
3 answers

Getting HEAD content with Python Requests

I'm trying to parse the result of a HEAD request done using the Python Requests library, but can't seem to access the response content. According to the docs, I should be able to access the content from requests.Response.text. This works fine for me…
Yarin
  • 173,523
  • 149
  • 402
  • 512
23
votes
4 answers

Unable to locate FromStream in Image class

I have the following code: Image tmpimg = null; HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); Stream stream =…
user896692
  • 2,351
  • 7
  • 36
  • 57
22
votes
5 answers

python-requests: order get parameters

I am implementing a client library for a private HTTP-API using python requests. The API(which I don't control) expects the parameters to be in a certain order, but python-requests doesn't honor a sorted dict as parameter. This is what i…
tback
  • 11,138
  • 7
  • 47
  • 71
16
votes
2 answers

Server 415 Response code

I am using Jetty web server, and Jersey for REST handling. I defined: @POST @Path("/sendMessage") @Consumes ({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) public Response sendMessage(@Context final UriInfo uriInfo) { …
Michael A
  • 5,770
  • 16
  • 75
  • 127
1
2 3
23 24