Content deleted Content added
the |
image + rfc link |
||
Line 1:
In the [[World Wide Web]], a '''query string''' is the part of a [[URL]] that contains data to be passed to [[Common Gateway Interface|CGI]] programs.
[[Image:Url.png|frame|The [[mozilla]] URL ___location bar showing an URL with the query string <code>title=Main_page&action=raw]]
When a [[web page]] is requested via the [[HyperText Transfer Protocol]], the server locates a file in its [[file system]] based on the requested [[URL]]. This file may be a regular file or a program. In the second case, the server may (depending on its configuration) run the program, sending its output as the required page. The query string is a part of the URL which is passed to the program. This way, the URL can encode some data that is accessible to the program generating the web page.
Line 23 ⟶ 25:
* The query string is composed of a series of parameter=value pairs
* The parameter-value pairs are each separated by an [[equal sign]].
* The series of pairs is separated by the [[ampersand]], '&'
For each [[Field (computer science)|field]] of the form, the query string contains a pair parameter=value. Web forms may include fields that are not visible to the user, and these fields are included in the query string when the form is submitted.
Line 31 ⟶ 33:
The parameter=value pairs in the query string are encoded according to a schema known as [[URL Encoding]]. This is necessary because some characters cannot be part of a URL (for example, the space) and some other characters have a special meaning in a URL (for example, the character <code>#</code>, which is used to locate a point within a page).
In particular, [[Request for Comments|RFC 1738]] specifies that “only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL”. All characters in a query string can be replaced by their hexadecimal value precedeed by the symbol <code>%</code>. For example, the equal sign can be replaced by <code>%3D</code>. All characters can be replaced this way; for the characters that are forbidden in a query string, this is not only possible but necessary.
The space character can be also represented by <code>+</code>.
|