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

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

Issue 224084: code review 224084: http: corrected comment for Response.GetHeader. (Closed)
Left Patch Set: Created 15 years ago
Right Patch Set: code review 224084: http: corrected comment for Response.GetHeader. Created 15 years 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 Response reading and parsing. 5 // HTTP Response reading and parsing.
6 6
7 package http 7 package http
8 8
9 import ( 9 import (
10 "bufio" 10 "bufio"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 key = CanonicalHeaderKey(key) 145 key = CanonicalHeaderKey(key)
146 146
147 oldValues, oldValuesPresent := r.Header[key] 147 oldValues, oldValuesPresent := r.Header[key]
148 if oldValuesPresent { 148 if oldValuesPresent {
149 r.Header[key] = oldValues + "," + value 149 r.Header[key] = oldValues + "," + value
150 } else { 150 } else {
151 r.Header[key] = value 151 r.Header[key] = value
152 } 152 }
153 } 153 }
154 154
155 // GetHeader returns the value of the response header with the given 155 // GetHeader returns the value of the response header with the given key.
156 // key, and true. If there were multiple headers with this key, their 156 // If there were multiple headers with this key, their values are concatenated,
157 // values are concatenated, with a comma delimiter. If there were no 157 // with a comma delimiter. If there were no response headers with the given
158 // response headers with the given key, it returns the empty string and 158 // key, GetHeader returns an empty string. Keys are not case sensitive.
159 // false. Keys are not case sensitive. 159 func (r *Response) GetHeader(key string) (value string) {
160 func (r *Response) GetHeader(key string) (string, bool) { 160 » value, _ = r.Header[CanonicalHeaderKey(key)]
161 » value, ok := r.Header[CanonicalHeaderKey(key)] 161 » return
162 » return value, ok
163 } 162 }
164 163
165 // ProtoAtLeast returns whether the HTTP protocol used 164 // ProtoAtLeast returns whether the HTTP protocol used
166 // in the response is at least major.minor. 165 // in the response is at least major.minor.
167 func (r *Response) ProtoAtLeast(major, minor int) bool { 166 func (r *Response) ProtoAtLeast(major, minor int) bool {
168 return r.ProtoMajor > major || 167 return r.ProtoMajor > major ||
169 r.ProtoMajor == major && r.ProtoMinor >= minor 168 r.ProtoMajor == major && r.ProtoMinor >= minor
170 } 169 }
171 170
172 // Writes the response (header, body and trailer) in wire format. This method 171 // Writes the response (header, body and trailer) in wire format. This method
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 239 }
241 kva = kva[0:i] 240 kva = kva[0:i]
242 sort.SortStrings(kva) 241 sort.SortStrings(kva)
243 for _, l := range kva { 242 for _, l := range kva {
244 if _, err := io.WriteString(w, l); err != nil { 243 if _, err := io.WriteString(w, l); err != nil {
245 return err 244 return err
246 } 245 }
247 } 246 }
248 return nil 247 return nil
249 } 248 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

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