HeaderTooLong = &ProtocolError{"http header too long"};
BadContentLength = &ProtocolError{"invalid content length"};
ShortEntityBody = &ProtocolError{"entity body too short"};
+ NoEntityBody = &ProtocolError{"no entity body"};
BadHeader = &ProtocolError{"malformed http header"};
BadRequest = &ProtocolError{"invalid http request"};
BadHTTPVersion = &ProtocolError{"unsupported http version"};
// Write an HTTP request -- header and body -- in wire format.
// See Send for a list of which Request fields we use.
func (req *Request) write(w io.Writer) os.Error {
- uri := "/" + URLEscape(req.Url.Path);
+ uri := URLEscape(req.Url.Path);
if req.Url.RawQuery != "" {
uri += "?" + req.Url.RawQuery;
}
// ParseForm parses the request body as a form.
func (r *Request) ParseForm() (err os.Error) {
+ if r.Body == nil {
+ return NoEntityBody
+ }
ct, ok := r.Header["Content-Type"];
if !ok {
ct = "application/x-www-form-urlencoded"; // default