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

Side by Side Diff: src/pkg/net/http/request.go

Issue 11432044: code review 11432044: net/http: document NewRequest treating Reader as ReadCloser (Closed)
Patch Set: diff -r 95e1e4bd8da9 https://go.googlecode.com/hg/ Created 10 years, 8 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7 package http
8 8
9 import ( 9 import (
10 "bufio" 10 "bufio"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return 0, 0, false 417 return 0, 0, false
418 } 418 }
419 minor, err = strconv.Atoi(vers[dot+1:]) 419 minor, err = strconv.Atoi(vers[dot+1:])
420 if err != nil || minor < 0 || minor > Big { 420 if err != nil || minor < 0 || minor > Big {
421 return 0, 0, false 421 return 0, 0, false
422 } 422 }
423 return major, minor, true 423 return major, minor, true
424 } 424 }
425 425
426 // NewRequest returns a new Request given a method, URL, and optional body. 426 // NewRequest returns a new Request given a method, URL, and optional body.
427 //
428 // If the provided body is also an io.Closer, the returned
429 // Request.Body is set to body and will be closed by the Client
430 // methods Do, Post, and PostForm, and Transport.RoundTrip.
rog 2013/07/17 14:36:12 i'd also like to see a similar comment on Client.P
427 func NewRequest(method, urlStr string, body io.Reader) (*Request, error) { 431 func NewRequest(method, urlStr string, body io.Reader) (*Request, error) {
428 u, err := url.Parse(urlStr) 432 u, err := url.Parse(urlStr)
429 if err != nil { 433 if err != nil {
430 return nil, err 434 return nil, err
431 } 435 }
432 rc, ok := body.(io.ReadCloser) 436 rc, ok := body.(io.ReadCloser)
433 if !ok && body != nil { 437 if !ok && body != nil {
434 rc = ioutil.NopCloser(body) 438 rc = ioutil.NopCloser(body)
435 } 439 }
436 req := &Request{ 440 req := &Request{
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 func (r *Request) wantsHttp10KeepAlive() bool { 841 func (r *Request) wantsHttp10KeepAlive() bool {
838 if r.ProtoMajor != 1 || r.ProtoMinor != 0 { 842 if r.ProtoMajor != 1 || r.ProtoMinor != 0 {
839 return false 843 return false
840 } 844 }
841 return hasToken(r.Header.get("Connection"), "keep-alive") 845 return hasToken(r.Header.get("Connection"), "keep-alive")
842 } 846 }
843 847
844 func (r *Request) wantsClose() bool { 848 func (r *Request) wantsClose() bool {
845 return hasToken(r.Header.get("Connection"), "close") 849 return hasToken(r.Header.get("Connection"), "close")
846 } 850 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

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