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
7 answers

What is the maximum file size I can transfer using HTTP? And using FTP?

Added: I am conducting a study for a new system we're going to develop in my work. It consists in authenticating users, displaying what files they want to download and downloading them. Also, if the files are not readily available, the user can't…
Thiago Chaves
  • 9,218
  • 5
  • 28
  • 25
26
votes
4 answers

How do you make a GET request in Rust?

I noticed that Rust doesn't have a builtin library to deal with HTTP, it only has a net module that deals with raw IP and TCP protocols. I need to take a &str of the URL, make a HTTP GET request, and if successful return either a String or &str that…
Josh Weinstein
  • 2,788
  • 2
  • 21
  • 38
26
votes
2 answers

What is the difference between HTTP streaming and server sent events?

My understanding is that HTTP streaming involves the client sending an HTTP request and then response to the request being sent over time allowing the server to essentially push to the client. In what I have read it seems that SSEs operates along…
Bren
  • 3,516
  • 11
  • 41
  • 73
26
votes
2 answers

How many HTTP verbs are there?

I count 9 HTTP request methods (aka verbs): GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATCH The above from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods Is that it? will this ever change?
Purplejacket
  • 1,808
  • 2
  • 25
  • 43
26
votes
4 answers

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) in iOS 9 with Xcode 7.1

I am using iOS 9 as target & using Xcode 7.1, tried everything as my level best for all the solutions of ATS but didn't work. Below is the following error description coming at console. If any suggestion comes I will be obliged. Some of the key…
SAYAN NANDY
  • 373
  • 1
  • 3
  • 9
26
votes
5 answers

java.io.IOException: Server returned HTTP response code: 403 for URL

I want to download the mp3 file from url : "http://upload13.music.qzone.soso.com/30671794.mp3", i always got java.io.IOException: Server returned HTTP response code: 403 for URL. But it's ok when open the url using browser. Below is part of my…
Adao
  • 261
  • 1
  • 3
  • 3
26
votes
4 answers

Go http.Get, concurrency, and "Connection reset by peer"

I have between 1000-2000 webpages to download from one server, and I am using go routines and channels to achieve a high efficiency. The problem is that every time I run my program up to 400 requests fail with the error "connection reset by peer".…
fgblomqvist
  • 2,244
  • 2
  • 32
  • 44
26
votes
2 answers

How to Send a body of data to XMLHttpRequest that looks like this?

How do I format this correctly? var params = { "range":"Sheet1!A4:C4", "majorDimension": "ROWS", "values": [ ["Hello World","123", "456"] ], } Then send it using POST like : var xhr = new XMLHttpRequest(); xhr.open(method, url); …
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
26
votes
2 answers

HTTP status for "email not verified"

I have seen the list of all HTTP status codes. However to me it looks like there is no code for "email not verified" (used for authentication/authorization). Did you ever had the same "problem"? What HTTP status code did you use? I guess it should…
mosquito87
  • 4,270
  • 11
  • 46
  • 77
26
votes
3 answers

How to set Content-Type and Accept in angular2 getting error 415 Unsupported Media Type

How to set Content-Type and Accept in angular2? I am trying to send post call with content type(application/json) in header But for somereason it does not send, it always send text/plain; charset=UTF-8 in content type I am getting 415 Unsupported…
bonjour
  • 263
  • 1
  • 3
  • 5
26
votes
3 answers

What is the best way to send HTTP requests from Windows Powershell?

What is the best way to send HTTP requests from Windows Powershell?
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139
26
votes
5 answers

Is the only way of passing POST parameters in HTML through a form?

In HTML, you can send data from one page to another using a GET request in a couple of ways: http://www.example.com/somepage.php?data=1 ...or...
Philip Morton
  • 129,733
  • 38
  • 88
  • 97
26
votes
3 answers

Is gzip compression useful for mobile devices?

I'm wondering if anyone has a clue on whether the gzip compression is as much useful on mobile devices than it is on a desktop computer. Will the phone use more battery? Or will it save some because of the bandwidth saving? Will the page page load…
Savageman
  • 9,257
  • 6
  • 40
  • 50
26
votes
4 answers

Tunnel a localhost subdirectory through ngrok?

Objective: want to share a website preview using ngrok, which creates a tunnel from which my localhost can be seen with an url of something like mywebsite.ngrok.io Problem: I use WAMP and my localhost folder looks something like…
Pontiacks
  • 1,118
  • 2
  • 13
  • 23
26
votes
1 answer

RESTful HTTP DELETE method in .NET

I am new to web services. I am dealing with testing APIs in my project. In the previous version the company used GET and POST methods but not PUT and DELETE methods. For the HTTP DELETE method, I have browsed various websites where I found the…
VIBA
  • 263
  • 1
  • 3
  • 4