LEFT | RIGHT |
(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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 if !ok || i != len(vers) { | 419 if !ok || i != len(vers) { |
420 return 0, 0, false | 420 return 0, 0, false |
421 } | 421 } |
422 return major, minor, true | 422 return major, minor, true |
423 } | 423 } |
424 | 424 |
425 type chunkedReader struct { | 425 type chunkedReader struct { |
426 r *bufio.Reader | 426 r *bufio.Reader |
427 n uint64 // unread bytes in chunk | 427 n uint64 // unread bytes in chunk |
428 err os.Error | 428 err os.Error |
429 } | |
430 | |
431 func newChunkedReader(r *bufio.Reader) *chunkedReader { | |
432 return &chunkedReader{r: r} | |
433 } | 429 } |
434 | 430 |
435 func (cr *chunkedReader) beginChunk() { | 431 func (cr *chunkedReader) beginChunk() { |
436 // chunk-size CRLF | 432 // chunk-size CRLF |
437 var line string | 433 var line string |
438 line, cr.err = readLine(cr.r) | 434 line, cr.err = readLine(cr.r) |
439 if cr.err != nil { | 435 if cr.err != nil { |
440 return | 436 return |
441 } | 437 } |
442 cr.n, cr.err = strconv.Btoui64(line, 16) | 438 cr.n, cr.err = strconv.Btoui64(line, 16) |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 func (r *Request) expectsContinue() bool { | 800 func (r *Request) expectsContinue() bool { |
805 return strings.ToLower(r.Header.Get("Expect")) == "100-continue" | 801 return strings.ToLower(r.Header.Get("Expect")) == "100-continue" |
806 } | 802 } |
807 | 803 |
808 func (r *Request) wantsHttp10KeepAlive() bool { | 804 func (r *Request) wantsHttp10KeepAlive() bool { |
809 if r.ProtoMajor != 1 || r.ProtoMinor != 0 { | 805 if r.ProtoMajor != 1 || r.ProtoMinor != 0 { |
810 return false | 806 return false |
811 } | 807 } |
812 return strings.Contains(strings.ToLower(r.Header.Get("Connection")), "ke
ep-alive") | 808 return strings.Contains(strings.ToLower(r.Header.Get("Connection")), "ke
ep-alive") |
813 } | 809 } |
LEFT | RIGHT |