Questions tagged [http]

Hypertext Transfer Protocol (HTTP) is an application level network protocol that is used for the transfer of content on the World Wide Web.

HyperText Transfer Protocol (HTTP) uses a client-request/server-response model. The protocol is stateless, which means it does not require the server to retain information or status about each user for the duration of multiple requests. However, for performance reasons and to avoid the connection-latency issues of TCP, techniques like persistent, parallel or pipelined connections may be used.

The request is sent with an HTTP method:

  • HEAD - used to retrieve the GET response header without the actual content (i.e., just the metadata in the content).
  • GET - used to retrieve data, where the request body is ignored.
  • POST - used to send data, contained in the request body, to the server.

These are all the methods supported by older browsers, but the HTTP 1.1 specification includes a few more: PUT, DELETE, TRACE, OPTIONS, CONNECT and PATCH.

The response is returned with a status code:

  • 1xx are informational
  • 2xx indicates success, most pages will have a 200 status
  • 3xx are used for redirections
  • 4xx codes are used for errors with the request, the commonest being 404 for "Page not found"
  • 5xx are used for server errors

Both the request and response are made up of a header and an optional body.

The header contains a list of key-value pairs, separated using new lines and colons. For example, a request may have headers like this:

Proxy-Connection: keep-alive
Referer: URL
User-Agent: browser name or client application
Accept-Encoding: gzip,deflate
Accept-Language: en-GB

Note that in the example the request is telling the server that the response can be sent with the body compressed with either gzip or DEFLATE encoding.

The request needs a body if it is sending additional data to the server, for instance, if sending information entered into a form.

The response headers will include information telling the client how to deal with the response data, for instance, whether they can cache the data (and how long for).

The response body will have the requested data, such as the HTML of a web page or image data.

HTTP is used by browsers to retrieve web content, but can also be used for data APIs, for instance, as a , , or service.

Versions

Resources

Related Tags

67879 questions
26
votes
8 answers

Parse Accept Header

Does anyone have any suggestions (or a regular expression) for parsing the HTTP Accept header? I am trying to do some content-type negotiation in ASP.NET MVC. There doesn't seem to be a built in way (which is fine, because there are a lot of schools…
Doug McClean
  • 14,265
  • 6
  • 48
  • 70
26
votes
7 answers

How to get http request origin in php

I want to create an API, and to authenticate API consumers, I will provide an API KEY, App-id and App-Secret. The problem is that I want to know where the http Request is coming from, so that I can know if the Host that is making que request is the…
m_junior
  • 591
  • 1
  • 8
  • 19
26
votes
5 answers

How to handle ETIMEDOUT error?

How to handle etimedout error on this call ? var remotePath = "myremoteurltocopy" var localStream = fs.createWriteStream("myfil");; var out = request({ uri: remotePath }); out.on('response', function (resp) { if…
mcbjam
  • 7,344
  • 10
  • 32
  • 40
26
votes
3 answers

Angular js - detect when all $http() have finished

Ok i have tons of $http() calls all around the app code, i'm wondering is there any way / best practice to detect when all $http() around the app have finished ( success/error donesn't matter what they return, just need to know if finished )? So…
itsme
  • 48,972
  • 96
  • 224
  • 345
26
votes
4 answers

Standard method for HTTP partial upload, resume upload

I'm developing http client/server framework, and looking for the correct way to handle partial uploads (the same as for downloads using GET method with Range header). But, HTTP PUT is not intended to be resumed. And PATCH method, as i know, doesn't…
26
votes
2 answers

Difference between multipart and chunked protocol?

Can some experts explain the differences between the two? Is it true that chunked is a streaming protocol and multipart is not? What is the benefit of using multipart?
user776635
  • 861
  • 3
  • 9
  • 13
26
votes
2 answers

JAX/Jersey Custom error code in Response

In Jersey, how can we 'replace' the status string associated with a known status code? e.g. return Response.status(401).build(); generates a HTTP response that contains: HTTP/1.1 401 Unauthorized I (not me, but the client application) would like…
user245717
26
votes
3 answers

Is safe to use "X-..." header in a HTTP response?

I have to pass a meta-information in my HTTP response so I figured out that I could use the response header, for instance "X-MyData: 123456". Is that safe? I mean, there is a possibility that a client proxy remove this header? Thanks!
Eduardo Cobuci
  • 5,621
  • 4
  • 25
  • 27
26
votes
3 answers

What is the correct behavior expected of an HTTP POST => 302 redirect to GET?

What is the correct behavior expected of a POST => 302 redirect to GET? In chrome (and likely most every browser), after I POST (to a resource that wants me to redirect) and I receive a 302 redirect, the browser automatically issues a GET on the…
Joshua Ball
  • 23,260
  • 6
  • 27
  • 29
26
votes
1 answer

why does http use CRLF as line delimiter?

As I know, use LF as line delimiter is quite popular, but I'm wondering why many text protocol like HTTP, FTP use CRLF as its line delimiter? I don't think these protocols are invented for old typewriters, so is there any historic reason for this? I…
otakustay
  • 11,817
  • 4
  • 39
  • 43
26
votes
1 answer

Python bottle module causes "Error: 413 Request Entity Too Large"

Using Python's module bottle, I'm getting HTTP 413 error when posting requests of body size > bottle's internal MEMFILE_MAX constant. Minimal working example is shown below. Server part (server.py): from bottle import * @post('/test') def test(): …
Tregoreg
  • 18,872
  • 15
  • 48
  • 69
26
votes
4 answers

How much network overhead does TLS add compared to a non-encrypted connection?

(Approximately) how many more bits of data must be transferred over the network during an encrypted connection compared to an unencrypted connection? IIUC, once the TLS handshake has completed, the number of bits transferred is equal to those…
Daniel S. Sterling
  • 1,309
  • 2
  • 15
  • 19
26
votes
8 answers

Why does my form submit in IE but not in Chrome?

I have a form with . In Chrome submit doesn't do anything. On a Network tab in developer tools I see nothing. No errors in developer tools either. Meanwhile, if I do save a page and open a saved page, then after I press submit…
dhblah
  • 9,751
  • 12
  • 56
  • 92
26
votes
2 answers

RESTful API endpoint for adding/removing array elements?

I have RESTful API built on top of a MongoDB store, so it's nice that you can store arrays. It's straightforward to create a new resource like this: POST /users { items: [ 1001, 1002, 1003 ] } But how would the HTTP endpoint for adding a…
thatmarvin
  • 2,800
  • 4
  • 22
  • 31
26
votes
4 answers

How to obtain numeric HTTP status codes in PowerShell

I know of a few good ways to build web clients in PowerShell: the .NET classes System.Net.WebClient and System.Net.HttpWebRequest, or the COM object Msxml2.XMLHTTP. From what I can tell, the only one which gives you access to the numeric status…
halr9000
  • 9,879
  • 5
  • 33
  • 34
1 2 3
99
100