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
1 answer

Poorly-balanced socket accepts with Linux 3.2 kernel vs 2.6 kernel

I am running a fairly large-scale Node.js 0.8.8 app using Cluster with 16 worker processes on a 16-processor box with hyperthreading (so 32 logical cores). We are finding that since moving to the Linux 3.2.0 kernel (from 2.6.32), the balancing of…
Brett
  • 3,478
  • 1
  • 22
  • 23
26
votes
5 answers

HATEOAS Rel - Any Standards Yet?

I'm just starting to write a client implementation for a WebAPI I'm currently building. The API already employs HATEOAS so I'm writing the client accordingly. I'm using RestSharp as the base for the client. The Client is passed the api base url at…
Jammer
  • 9,969
  • 11
  • 68
  • 115
26
votes
3 answers

Sending http post request in Ruby by Net::HTTP

I'm sending a request with custom headers to a web service. require 'uri' require 'net/http' uri = URI("https://api.site.com/api.dll") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true headers = { 'HEADER1' => "VALUE1", …
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
26
votes
1 answer

Good apache http server tutorials for beginners

I have just installed apache server on my system. Right now have very limited knowledge about apache. I intend to use it to write scripts that can "get" a given data from a given url and after processing it "post" to a different url. I just want to…
Dilletante
  • 1,801
  • 4
  • 19
  • 18
26
votes
3 answers

It's possible to share a cookie between 'some' subdomains?

I've been reading some posts about web performance, one of the points is to serve static content from a cookie-free domain, my question is: Can I share cookies between, let's say example.com and www.example.com, while excluding static1.example.com,…
Cesar
  • 4,076
  • 8
  • 44
  • 68
26
votes
2 answers

PhantomJS doesn't send authentication header

I'm trying to open a web page which requires HTTP authentication, in PhantomJS. My script is based off the loadspeed.js example: var page = require('webpage').create(), t, address; page.settings.userName = "user"; page.settings.password =…
Karl Barker
  • 11,095
  • 3
  • 21
  • 26
25
votes
4 answers

Relative Path, but for Port?

We are all familiar with relative paths: A relative path to ./images/hello.jpg from http://www.domain.com/hey links to http://www.domain.com/hey/images/hello.jpg. Problem: How do you state a relative path to http://www.domain.com:1234 when you are…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
25
votes
5 answers

HttpClient in java

I want to use a simple HttpClient. However, it appears sun.net.www.http.HttpClient is inaccessible. Also, com.ibm.ws.http.HTTPConnection - appears to be more supporting of http server and not client. Why? Because when I create an instance of…
computeAlot
  • 267
  • 1
  • 3
  • 3
25
votes
2 answers

How does requests' stream=True option streams data one block at a time?

I'm using the following code to test how many seconds an HTTP connection can be kept alive: start_time = time.time() try: r = requests.get(BIG_FILE_URL, stream=True) total_length = r.headers['Content-length'] for chunk in…
Tom
  • 1,203
  • 4
  • 21
  • 36
25
votes
9 answers

Access blocked by CORS policy: Response to preflight request doesn't pass access control check

I'm trying to create a user administration API for my web app. When I send an API call from my frontend to my backend, a cors error occurs. How can the cors problem be solved? I've read a lot of threads, but I haven't made any progress. Error after…
laprof
  • 1,246
  • 3
  • 14
  • 27
25
votes
3 answers

Why does the encoding's of a URL and the query string part differ?

I was researching why my query parameters have plus + signs in it instead of %20 and why they have strings like %C3%BC instead of a ü (UTF-8) as an encoded URL does. After 2 hours of thinking my webapp is not compatible to the URL encoding standard…
moritz
  • 5,094
  • 1
  • 26
  • 33
25
votes
7 answers

Cannot push Git to remote repository with http/https

I have a Git repository in a directory served by apache on a server. I have configured WebDAV and it seems to be running correctly. Litmus returns 100% success. I can clone my repository from a remote host, but when trying to push over http or…
Clément
  • 602
  • 1
  • 8
  • 14
25
votes
1 answer

How to read request body twice in Golang middleware?

In a middleware, I want to read request body to perform some checks. Then, the request is passed to the next middleware where the body will be read again. Here's what I do: bodyBytes, _ := ioutil.ReadAll(req.Body) req.Body =…
Sergey
  • 1,168
  • 2
  • 13
  • 28
25
votes
3 answers

Can a URL have an asterisk?

I notice Wikipedia allows them in their URLs, is it legit or does anyone know where it will give me problems?
Kristopher Ives
  • 5,838
  • 7
  • 42
  • 67
25
votes
1 answer

Sending POST request in Golang with header

I create my form like this: form := url.Values{} form.Add("region", "San Francisco") if len(params) > 0 { for i := 0; i < len(params); i += 2 { form.Add(params[i], params[i+1]) } testLog.Infof("form %v", form) Now if I…
Jana
  • 5,516
  • 5
  • 23
  • 29
1 2 3
99
100