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
22
votes
2 answers

Wildfly 9 http to https

I want to redirect the request from HTTP to HTTPS. I am using wildfly 9. After a google search I found the following, but it is not working. I hope somebody
phil
  • 221
  • 1
  • 2
  • 4
22
votes
7 answers

How to tell why a cookie is not being sent?

I'm using chrome and I'm wondering if there is either an extension or a method to tell why a cookie is not being sent. I have one request I'm making to http://dev/login and it's returning, Set-Cookie:DevId=cffbc7e688864b6811f676e181bc29e6;…
user157251
  • 64,489
  • 38
  • 208
  • 350
22
votes
6 answers

NodeJS and HTTP Client - Are cookies supported?

NodeJS is a fantastic tool and blazing fast. I'm wondering if HTTPClient supports cookies and if can be used in order to simulate very basic browser behaviour! Help would be very much appreciated! =) EDIT: Found this: node-httpclient (seems…
RadiantHex
  • 22,589
  • 43
  • 141
  • 236
22
votes
3 answers

How to clone a HttpRequestMessage when the original request has Content?

I'm trying to clone a request using the method outlined in this answer: https://stackoverflow.com/a/18014515/406322 However, I get an ObjectDisposedException, if the original request has content. How can you reliably clone a HttpRequestMessage?
Prabhu
  • 11,837
  • 31
  • 115
  • 194
22
votes
1 answer

express 4.x redirect http to https

I have the following code : var https = require('https'); var http = require('http'); var express = require('express'); var app = express(); var router = express.Router(); app.use('/', router); //have 'server'…
uray
  • 10,130
  • 9
  • 46
  • 73
22
votes
1 answer

Set form submit header

Is there any way to set the HTTP header fields of a HTML form submit request? I need to make an authenticated request to a URL, so I need to set a header field. I can't use AJAX because of cross-domain restrictions.
akula1001
  • 4,378
  • 12
  • 39
  • 55
22
votes
1 answer

HTTP PATCH: Handling arrays, deletion, and nested key creation

I'm looking for a practical guide to implementing the PATCH verb for partial updates of a noun in a RESTful api using JSON. Understanding that PATCH is for partial updates, we lack still standardization around the syntax for deleting keys, creating…
SimplGy
  • 18,875
  • 14
  • 95
  • 138
22
votes
4 answers

Python 'requests' library - define specific DNS?

In my project I'm handling all HTTP requests with python requests library. Now, I need to query the http server using specific DNS - there are two environments, each using its own DNS, and changes are made independently. So, when the code is…
Taku
  • 342
  • 1
  • 4
  • 13
22
votes
4 answers

What is the non-standard HTTP verb "DEBUG" used for in ASP.NET/IIS?

I am reading a report from a "web application security" company, whom have been scanning a few websites of the company I am working for. It appears from the report - which seems written without any human involvement - that several attempts where…
Jørn Schou-Rode
  • 35,883
  • 13
  • 81
  • 120
22
votes
5 answers

GET request can be bookmarked and POST can not . Can anybody explain on this?

I am studying the HTTP methods. I read that GET request can be bookmarked and POST request can not be bookmarked. Can anybody explain this with an example? Thanks
giri
  • 24,958
  • 61
  • 134
  • 175
22
votes
3 answers

Is Content-Type HTTP header always required?

This question is about browser behavior as well as protocol specification for linking, importing, including or ajaxing css, js, image and other resources from within html, js or css files. While testing static files and compressed content delivery…
Hamid Sarfraz
  • 1,066
  • 1
  • 13
  • 32
22
votes
6 answers

How can I send a http delete request from browser?

Is there a way to send a DELETE request from a website, using xmlhttprequest or something similar?
Kalvaresin
  • 221
  • 1
  • 2
  • 3
22
votes
9 answers

GET vs POST in AJAX?

Why are there GET and POST requests in AJAX as it does not affect page URL anyway? What difference does it make by passing sensitive data over GET in AJAX as the data is not getting reflected to page URL?
Xinus
  • 26,861
  • 26
  • 111
  • 160
22
votes
4 answers

Using the PUT method with Express.js

I'm trying to implement update functionality to an Express.js app, and I'd like to use a PUT request to send the new data, but I keep getting errors using PUT. From everything I've read, it's just a matter of using app.put, but that isn't working. …
Brandon
  • 2,563
  • 6
  • 16
  • 21
22
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
  • 21,272
  • 6
  • 22
  • 26