Chapter 11. Plain Text, JSON, and XML
By now, nearly all the important aspects of converting PHP code to Node.js code have been covered. This chapter covers one remaining topic of relatively minor importance: data formats.
If a client uses an HTTP GET to pass data, the data is sent as URL parameters, which on most web browsers are shown in the address bar after the question mark (?). If there is no question mark (?), there is no data sent; the fact that an HTTP GET was made to a certain URL is the only piece of data. If there is a question mark (?) and URL parameters, the parameters are in the “URL-encoded” format. For example, the following shows some URL-encoded data:
URL-encoded data is name/value pairs separated by ampersands (&). Special characters, such as spaces ( ), are encoded using percent signs (%) followed by a specific two-digit hexadecimal number.
An HTTP GET request concatenates the URL-encoded data to the end of the URL in the first line in the HTTP header. The following shows an HTTP GET request that sends ...