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:

359 questions
199
votes
3 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
  • 9,394
  • 9
  • 53
  • 68
181
votes
10 answers

Proxies with Python 'Requests' module

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…
user1064306
121
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
  • 12,617
  • 20
  • 67
  • 104
87
votes
2 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
  • 4,294
  • 9
  • 35
  • 55
77
votes
2 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
  • 11,331
  • 26
  • 71
  • 124
71
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
  • 951
  • 1
  • 12
  • 20
53
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
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
  • 17,946
  • 16
  • 88
  • 101
48
votes
7 answers

how to post plain text to ASP.NET Web API endpoint?

I have an ASP.NET Web API endpoint with controller action defined as follows : [HttpPost] public HttpResponseMessage Post([FromBody] object text) If my post request body contains plain text ( i.e. should not be interpreted as json, xml, or any…
BaltoStar
  • 6,511
  • 13
  • 46
  • 67
47
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,120
  • 4
  • 29
  • 40
41
votes
10 answers

Putting a `Cookie` in a `CookieJar`

I'm using the new Python Requests library to make http requests. I obtain a cookie from the server as text. How do I turn that into a CookieJar with the cookie in it?
Ram Rachum
  • 71,442
  • 73
  • 210
  • 338
39
votes
6 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
  • 43,517
  • 50
  • 120
  • 169
24
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
  • 43,517
  • 50
  • 120
  • 169
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,251
  • 7
  • 34
  • 56
22
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
  • 144,097
  • 139
  • 361
  • 489
1
2 3
23 24