Besides the URI and headers, a request message can contain additional information in the form of parameters. If the URI identifies a server-side program for displaying weather information, for example, request parameters can provide information about which city the user wants to see a forecast for. In an e-commerce application, the URI may identify a program that processes orders, using the customer number and the list of items to be purchased as parameters.
Parameters can be sent in one of two ways: tacked on to the URI in the form of a query string or sent as part of the request message body. This is an example of a URL with a query string:
The query string starts with a question mark (
and consists of name/value pairs separated by ampersands
&). These names and values must
meaning that special characters, such as whitespace, question marks,
ampersands, and all other nonalphanumeric characters are encoded so
that they don’t get confused with characters used to
separate name/value pairs and other parts of the URI. In this
example, the space between
Beach is encoded as a plus sign. Other special
characters are encoded as their corresponding hexadecimal ASCII
value; for instance, a question mark is encoded as
%3F. When parameters are sent as part of the
request body, they follow the same syntax: URL-encoded name/value
pairs separated by ampersands.