Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1140)

Delta Between Two Patch Sets: src/pkg/http/request.go

Issue 4607052: code review 4607052: os.Error API: don't export os.ErrorString, use os.NewEr... (Closed)
Left Patch Set: Created 13 years, 9 months ago
Right Patch Set: diff -r 6e3e06fb2dc3 https://go.googlecode.com/hg/ Created 13 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/http/fs.go ('k') | src/pkg/http/transport.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // HTTP Request reading and parsing. 5 // HTTP Request reading and parsing.
6 6
7 // Package http implements parsing of HTTP requests, replies, and URLs and 7 // Package http implements parsing of HTTP requests, replies, and URLs and
8 // provides an extensible HTTP server and a basic HTTP client. 8 // provides an extensible HTTP server and a basic HTTP client.
9 package http 9 package http
10 10
(...skipping 17 matching lines...) Expand all
28 const ( 28 const (
29 maxLineLength = 4096 // assumed <= bufio.defaultBufSize 29 maxLineLength = 4096 // assumed <= bufio.defaultBufSize
30 maxValueLength = 4096 30 maxValueLength = 4096
31 maxHeaderLines = 1024 31 maxHeaderLines = 1024
32 chunkSize = 4 << 10 // 4 KB chunks 32 chunkSize = 4 << 10 // 4 KB chunks
33 defaultMaxMemory = 32 << 20 // 32 MB 33 defaultMaxMemory = 32 << 20 // 32 MB
34 ) 34 )
35 35
36 // ErrMissingFile is returned by FormFile when the provided file field name 36 // ErrMissingFile is returned by FormFile when the provided file field name
37 // is either not present in the request or not a file field. 37 // is either not present in the request or not a file field.
38 var ErrMissingFile = os.ErrorString("http: no such file") 38 var ErrMissingFile = os.NewError("http: no such file")
39 39
40 // HTTP request parsing errors. 40 // HTTP request parsing errors.
41 type ProtocolError struct { 41 type ProtocolError struct {
42 » os.ErrorString 42 » ErrorString string
43 } 43 }
44
45 func (err *ProtocolError) String() string { return err.ErrorString }
44 46
45 var ( 47 var (
46 ErrLineTooLong = &ProtocolError{"header line too long"} 48 ErrLineTooLong = &ProtocolError{"header line too long"}
47 ErrHeaderTooLong = &ProtocolError{"header too long"} 49 ErrHeaderTooLong = &ProtocolError{"header too long"}
48 ErrShortBody = &ProtocolError{"entity body too short"} 50 ErrShortBody = &ProtocolError{"entity body too short"}
49 ErrNotSupported = &ProtocolError{"feature not supported"} 51 ErrNotSupported = &ProtocolError{"feature not supported"}
50 ErrUnexpectedTrailer = &ProtocolError{"trailer header without chunked transfer encoding"} 52 ErrUnexpectedTrailer = &ProtocolError{"trailer header without chunked transfer encoding"}
51 ErrMissingContentLength = &ProtocolError{"missing ContentLength in HEAD response"} 53 ErrMissingContentLength = &ProtocolError{"missing ContentLength in HEAD response"}
52 ErrNotMultipart = &ProtocolError{"request Content-Type isn't mul tipart/form-data"} 54 ErrNotMultipart = &ProtocolError{"request Content-Type isn't mul tipart/form-data"}
53 ErrMissingBoundary = &ProtocolError{"no multipart boundary param Co ntent-Type"} 55 ErrMissingBoundary = &ProtocolError{"no multipart boundary param Co ntent-Type"}
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 if r.Form != nil { 699 if r.Form != nil {
698 return 700 return
699 } 701 }
700 702
701 r.Form = make(Values) 703 r.Form = make(Values)
702 if r.URL != nil { 704 if r.URL != nil {
703 err = parseQuery(r.Form, r.URL.RawQuery) 705 err = parseQuery(r.Form, r.URL.RawQuery)
704 } 706 }
705 if r.Method == "POST" { 707 if r.Method == "POST" {
706 if r.Body == nil { 708 if r.Body == nil {
707 » » » return os.ErrorString("missing form body") 709 » » » return os.NewError("missing form body")
708 } 710 }
709 ct := r.Header.Get("Content-Type") 711 ct := r.Header.Get("Content-Type")
710 switch strings.Split(ct, ";", 2)[0] { 712 switch strings.Split(ct, ";", 2)[0] {
711 case "text/plain", "application/x-www-form-urlencoded", "": 713 case "text/plain", "application/x-www-form-urlencoded", "":
712 const maxFormSize = int64(10 << 20) // 10 MB is a lot of text. 714 const maxFormSize = int64(10 << 20) // 10 MB is a lot of text.
713 b, e := ioutil.ReadAll(io.LimitReader(r.Body, maxFormSiz e+1)) 715 b, e := ioutil.ReadAll(io.LimitReader(r.Body, maxFormSiz e+1))
714 if e != nil { 716 if e != nil {
715 if err == nil { 717 if err == nil {
716 err = e 718 err = e
717 } 719 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 func (r *Request) expectsContinue() bool { 810 func (r *Request) expectsContinue() bool {
809 return strings.ToLower(r.Header.Get("Expect")) == "100-continue" 811 return strings.ToLower(r.Header.Get("Expect")) == "100-continue"
810 } 812 }
811 813
812 func (r *Request) wantsHttp10KeepAlive() bool { 814 func (r *Request) wantsHttp10KeepAlive() bool {
813 if r.ProtoMajor != 1 || r.ProtoMinor != 0 { 815 if r.ProtoMajor != 1 || r.ProtoMinor != 0 {
814 return false 816 return false
815 } 817 }
816 return strings.Contains(strings.ToLower(r.Header.Get("Connection")), "ke ep-alive") 818 return strings.Contains(strings.ToLower(r.Header.Get("Connection")), "ke ep-alive")
817 } 819 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b