| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package prpc | 5 package prpc |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "io" | 10 "io" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 req.Body = ioutil.NopCloser(bytes.NewReader(in)) | 197 req.Body = ioutil.NopCloser(bytes.NewReader(in)) |
| 198 res, err := ctxhttp.Do(ctx, c.getHTTPClient(), req) | 198 res, err := ctxhttp.Do(ctx, c.getHTTPClient(), req) |
| 199 if res != nil && res.Body != nil { | 199 if res != nil && res.Body != nil { |
| 200 defer res.Body.Close() | 200 defer res.Body.Close() |
| 201 } | 201 } |
| 202 if c.testPostHTTP != nil { | 202 if c.testPostHTTP != nil { |
| 203 err = c.testPostHTTP(ctx, err) | 203 err = c.testPostHTTP(ctx, err) |
| 204 } | 204 } |
| 205 if err != nil { | 205 if err != nil { |
| 206 // Treat all errors here as transient. | 206 // Treat all errors here as transient. |
| 207 » » » » return errors.Annotate(err).Reason("failed to se
nd request"). | 207 » » » » return errors.Annotate(err, "failed to send requ
est").Tag(transient.Tag).Err() |
| 208 » » » » » Tag(transient.Tag).Err() | |
| 209 } | 208 } |
| 210 | 209 |
| 211 if options.resHeaderMetadata != nil { | 210 if options.resHeaderMetadata != nil { |
| 212 *options.resHeaderMetadata = metadataFromHeaders
(res.Header) | 211 *options.resHeaderMetadata = metadataFromHeaders
(res.Header) |
| 213 } | 212 } |
| 214 contentType = res.Header.Get("Content-Type") | 213 contentType = res.Header.Get("Content-Type") |
| 215 | 214 |
| 216 // Read the response body. | 215 // Read the response body. |
| 217 buf.Reset() | 216 buf.Reset() |
| 218 var body io.Reader = res.Body | 217 var body io.Reader = res.Body |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 if len(h) == 0 { | 363 if len(h) == 0 { |
| 365 return nil | 364 return nil |
| 366 } | 365 } |
| 367 | 366 |
| 368 md := make(metadata.MD, len(h)) | 367 md := make(metadata.MD, len(h)) |
| 369 for k, v := range h { | 368 for k, v := range h { |
| 370 md[strings.ToLower(k)] = v | 369 md[strings.ToLower(k)] = v |
| 371 } | 370 } |
| 372 return md | 371 return md |
| 373 } | 372 } |
| OLD | NEW |