Parameters are one of the essential components of the HTTP protocol, which is an optional entity but can be used in combination for various purposes. In this chapter, you will learn about the various parameters of HTTP protocols, their syntax, and how they can be used for communication.
What Is HTTP Parameter?
When the HTTP method is used to request certain resources from the web server, the client also sends some parameters to the web server. These parameters are in a pair of names and their corresponding values, which are called HTTP parameters.
HTTP Parameter Types
- HTTP Version
- Uniform Resource Identifier (URI)
- Date and Time Format
- Character Set
- Media Types
- Language Tag
Let us now discuss each of them in detail.
HTTP makes use of the "<major>.<minor>" numbering system for designating the version of the protocol. This protocol's versioning policy is proposed to allow the sender to specify the message format and its capability to understand HTTP communication further.
"HTTP" "/" 1*DIGIT "." 1* DIGIT
GET http://www.example.com/ HTTP/1.1
It is to be noted that the <major> and <minor> numbers should be treated as separate integers where each has the potential to increment higher than a single digit.
Uniform Resource Identifier (URI)
URIs are also known as WWW addresses, Universal Resource Identifiers, Universal Document Identifiers, Uniform Resource Name (URN), and the popular Uniform Resource Locator (URL). These are basically formatted, case-insensitive threads that contain a name, location, etc., to identify a web service, a resource, a website, etc.
URI = "http :" "//" host[ ":" port ][ abs_path ["?" query]]
Here, if your port is empty or not assigned with any value, port 80 is considered the default HTTP port, and the empty abs_path is equivalent is defined as the abs_path of "/".
GET http://www.example.com/ HTTP/1.1
Date and Time Format
HTTP applications allow us to use three different formats to represent date-time stamps:
Sat, 28 Aug 1993 08:49:37 GMT; RFC 822, updated by RFC 1123 Saturday, 28-Aug-93 08:49:37 GMT; RFC 850, obsoleted by RFC 1036 Sat Nov 28 08:49:37 1993; ANSI C's asctime() format
Each HTTP date/time stamp must be presented in Greenwich Mean Time (GMT) without exception. The first date-time format is chosen as an Internet standard representing a fixed-length separation defined by RFC 1123.
The next format is a commonly used format based on the older RFC 850 date-time format with no 4-digit representation of the year. The last is the standard date-time format of ANSI.
Character sets are used to indicate character sets that are given as preference by the client. Various character sets exist that are listed and separated by commas. If the value is not specified, the default US-ASCII is used.
Accept-Charset: <charset>, <charset>;q=
Accept-Charset: utf-8, iso-8859-1;q=0.7
Internet Media Types are used by HTTP as the 'Content-Type' as well as 'Accept header' fields for providing open and extensible data type for type negotiation. Parameters may trail the type/subtype as attribute/value pairs. All these media-type values must be registered under the Internet Assigned Numbers Authority (IANA).
Accept: type "/" subtype *( ";" parameter )
Accept: application/vnd.linn.user+json; version=1
Language tags in HTTP are used to identify a natural language that is spoken, written, and conveyed by humans for day to day communication. It excludes all computer languages. The registry and syntax of HTTP language tags are the same and are defined by RFC 1766. A language tag can contain more than one part.
Accept-Language: <language> or Accept-Language: *
It is to be noted that white spaces are not allowed within a tag. Also, all tags are case- insensitive. The IANA administers all the namespace of the standard language tags. Example of such languages are: en, en-US, en-cockney, i-cherokee, x-pig-latin