HTTP Request Header
HTTP clients and servers largely depend on the “Content-Type” header to determine how to parse the request/response body. Common values for the “Content-Type” header are
and request/response body should be processed as JSON, XML, PDF, Raw Stream, or Form Data respectively.
How is Form Data Sent?
99.99% of forms in your web applications will be
url-encoded and sent in the request body instead of the request URL for obvious reasons.
Parse Form Data with
func (r *Request) ParseForm() error
For all requests, ParseForm parses the raw query from the URL and updates r.Form. For POST, PUT, and PATCH requests, it also reads the request body, parses it as a form, and puts the results into both r.PostForm and r.Form. Request body parameters take precedence over URL query string values in r.Form. If the request Body's size has not already been limited by MaxBytesReader, the size is capped at 10MB. For other HTTP methods, or when the Content-Type is not application/x-www-form-urlencoded, the request Body is not read, and r.PostForm is initialized to a non-nil, empty value.
URL query parameters are also read in the
r.Form map object.
Written with StackEdit.