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

61925 questions
21
votes
4 answers

Why the error 404 happens when I access *.mp4 file by HTTP?

I have some shared folder over HTTP. Lets say: http://myserver/files And there are some filed like png, avi, jpg, mp4 and etc. I can easily access *.png or *.avi via browser (http://myserver/files/555.avi) but cannot access to *.mp4. So IIS gives…
DmitryBoyko
  • 32,983
  • 69
  • 281
  • 458
21
votes
2 answers

Is it possible to change the HTTP status code returned when proxy_pass gateway is down in nginx?

For SEO purposes, we would like to change the HTTP status code returned whenever the backend machine behind nginx goes down for some reason. We would like to change this to "503 Service Unavailable". As well as provide a Retry-After header to…
anonymous-one
  • 12,434
  • 18
  • 52
  • 80
21
votes
2 answers

http_build_query with same name parameters

Is there a way to build a query automatically with http_build_query using parameters with the same name? If I do something like array('foo' => 'x', 'foo' => 'y'); They are obviously overwritten within the array, but even if I do: array('foo' =>…
entropid
  • 5,714
  • 3
  • 29
  • 44
21
votes
5 answers

How can I find out whether a server supports the Range header?

I have been trying to stream audio from a particular point by using the Range header values but I always get the song right from the beginning. I am doing this through a program so am not sure whether the problem lies in my code or on the…
lostInTransit
  • 68,087
  • 58
  • 193
  • 270
21
votes
1 answer

node.js http server, detect when clients disconnect

I am using express with node.js for a http server. I store the response object so I can stream events down to the client on that channel. Is there a way to detect when the client disconnects? When I kill my client I can still write to the response…
Jeroen
  • 507
  • 1
  • 5
  • 15
21
votes
4 answers

Should deleting a non-existent resource result in a 404 in RESTful Rails?

In a brand new Rails application with a scaffolded RESTful model, the generated delete code looks like this: class BeersController < ApplicationController # DELETE /beers/1 # DELETE /beers/1.xml def destroy @beer = Beer.find(params[:id]) …
Brad
  • 797
  • 1
  • 6
  • 23
21
votes
1 answer

Need a basic server backend for iOS app

I'm currently developing an iOS app and have reached the point where I need to implement a server backend in order to support the core functionality. Essentially, the app deals with text strings that need to be uploaded to a server. After receiving…
Harrold Kenning
  • 213
  • 1
  • 2
  • 4
21
votes
3 answers

How to retrieve a webpage with C#?

How to retrieve a webpage and diplay the html to the console with C# ?
belaz
  • 1,380
  • 5
  • 17
  • 31
21
votes
2 answers

What is the difference between Content-Type...charset=X and Content-Encoding=X?

Is there any effective difference between Content-Encoding: UTF-8 Content-Type: text/html; charset=utf-8 ?
Seamus Abshere
  • 7,730
  • 2
  • 40
  • 59
21
votes
3 answers

How can I make a request with a bearer token in Go

I need to make a GET request to an API with a bearer token in the authorization request. How can I do this in Go? I have the following code, but I haven't had success. package main import ( "io/ioutil" "log" "net/http" ) func main() { …
Matheus Alcântara
  • 327
  • 1
  • 3
  • 4
21
votes
1 answer

Curl: Error: (3) Port number ended with '"'

I am trying to get a token of a dot net core 2.0 web api. This is what I am doing: C:\Users\danyb>curl -X POST -H 'Content-Type:application/json'^ Mehr? -d '{\"username\":\"mario\",\"password\":\"secret\"}'^ Mehr? localhost:56183/api/token [1/2]:…
BlockchainProgrammer
  • 1,333
  • 2
  • 11
  • 30
21
votes
1 answer

Cneonction and nnCoection HTTP headers

We have often some issues in terms of interoperability on the Web. One of these issues for browsers vendors is the wrongly spelled Connection HTTP header. The most common errors are given by these two forms. nnCoection: Cneonction: There are has…
karlcow
  • 6,781
  • 4
  • 34
  • 69
21
votes
3 answers

What does “state transfer” in Representational State Transfer (REST) refer to?

What does the State Transfer in Representational State Transfer refer to? Found some explanations about this (e.g. here) but I still don't understand. For example in the article it is said The representation places the client application in a…
user2011
  • 291
  • 3
  • 5
21
votes
4 answers

Is it possible to use subresource integrity with ES6 module imports?

Given code like this: import { el, mount } from 'https://unpkg.com/redom@3.2.1/dist/redom.es.js'; is there some way to enable subresource integrity verification to ensure that the CDN asset returns the expected content?
jens1o
  • 358
  • 3
  • 13
21
votes
5 answers

How is a HTTP PUT request typically issued?

I know HTTP PUT is an idempotent request that store something at a specific URI, according to the definition (quoted from the rfc) The PUT method requests that the enclosed entity be stored under the supplied Request-URI. But what is the definition…
Jeffrey04
  • 5,428
  • 10
  • 40
  • 62
1 2 3
99
100