FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Query_string

Query string

Contents
    Web forms
    Indexed search
Limitations

A query string is an optional component string of a URI, used to provide a set of one or more parameter values. When a URI is submitted to a server in a request to access, or otherwise interact with, a resource, the server may adapt its response in relation to those parameters.

An address bar on Google Chrome showing a URL with a two-parameter query string of An address bar showing a URL with a two-parameter query string of title=Query_string&action=edit https://example.com/over/there?name=ferret

An example URL with multiple query string parameters and a fragment identifier:

https://example.com/path/to/page?name=ferret&color=purple#fur</syntaxhighlight>"}},"i":0}}]}'/>
mailto:holly@example.com?subject=meeting&cc=assistant@example.com

Web forms

edit

One of the original uses was to contain the content of an HTML form, also known as web form. In particular, when a form containing the fields field1, field2, field3 is submitted, the content of the fields is encoded as a query string as follows:

field1=value1&amp;field2=value2&amp;field3=value3...</code>"}},"i":0}}]}'/>

field1=value1&field2=value2&field3=value3...

While there is no definitive standard, most web frameworks allow multiple values to be associated with a single field (e.g. field1=value1&field1=value2&field2=value3).

For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted.

This convention is a W3C recommendation. In the recommendations of 1999, W3C recommended that all web servers support semicolon separators in addition to ampersand separators to allow application/x-www-form-urlencoded query strings in URLs within HTML documents without having to entity escape ampersands. Since 2014, W3C recommends to use only ampersand as query separator.

The form content is only encoded in the URL's query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is submitted as the HTTP request body rather than being included in a modified URL.

Indexed search

edit

Before forms were added to HTML, browsers rendered the –

argument1+argument2+argument3...

Though the

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 # can be used to further specify a subsection (or fragment) of a document. In HTML forms, the character = is used to separate a name from a value. The URI generic syntax uses URL encoding to deal with this problem, while HTML forms make some additional substitutions rather than applying percent encoding for all such characters. SPACE is encoded as '+' or "%20".

HTML 5 specifies the following transformation for submitting HTML forms with the "GET" method to a web server. The following is a brief summary of the algorithm:

The octet corresponding to the tilde ("~") is permitted in query strings by RFC3986 but required to be percent-encoded in HTML forms to "%7E".

The encoding of SPACE as '+' and the selection of "as-is" characters distinguishes this encoding from RFC 3986.

Limitations

edit

As discussed in the HTTP specification, web services have sometimes imposed arbitrary length restrictions on URIs, rejecting requests they deem too long with 414 (Request-URI Too Long) status codes:

Various ad hoc limitations on request-line length are found in practice. It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets.

A workaround, applicable to HTML forms, is to configure the form to be submitted with the POST method instead of GET, thus the form data is sent in the HTTP request separated from the URI, rather than using the URI query string as in the GET method. Length limits on HTTP request bodies are typically much larger than those imposed on URI length.

  1. 1 2 3 T. Berners-Lee; R. Fielding; L. Masinter (January 2005). "RFC 3986".
  2. ↑ "4.10 Forms — HTML5".
  3. ↑ "<isindex>". HTML (HyperText Markup Language). Archived from the original on 2017-10-19. Retrieved 2015-11-21.
  4. ↑

View original on Wikipedia | Back | FazBrowse Home