Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: server/prpc/decoding.go

Issue 1638493004: server/prpc: updated server according to protocol (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package prpc 5 package prpc
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/base64" 9 "encoding/base64"
10 "fmt" 10 "fmt"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 case formatBinary, formatJSONPB, formatText: 57 case formatBinary, formatJSONPB, formatText:
58 return f, nil 58 return f, nil
59 59
60 default: 60 default:
61 panic("cannot happen") 61 panic("cannot happen")
62 } 62 }
63 } 63 }
64 64
65 // readMessage decodes a protobuf message from an HTTP request. 65 // readMessage decodes a protobuf message from an HTTP request.
66 // Does not close the request body. 66 // Does not close the request body.
67 func readMessage(r *http.Request, msg proto.Message) *httpError { 67 func readMessage(r *http.Request, msg proto.Message) *protocolError {
68 if msg == nil { 68 if msg == nil {
69 panicf("cannot decode to nil") 69 panicf("cannot decode to nil")
70 } 70 }
71 format, err := requestFormat(r.Header.Get(headerContentType)) 71 format, err := requestFormat(r.Header.Get(headerContentType))
72 if err != nil { 72 if err != nil {
73 // Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html# sec10.4.16 73 // Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html# sec10.4.16
74 return errorf(http.StatusUnsupportedMediaType, "Content-Type hea der: %s", err) 74 return errorf(http.StatusUnsupportedMediaType, "Content-Type hea der: %s", err)
75 } 75 }
76 76
77 buf, err := ioutil.ReadAll(r.Body) 77 buf, err := ioutil.ReadAll(r.Body)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 md[trimmedName] = append(md[trimmedName], string (decoded)) 158 md[trimmedName] = append(md[trimmedName], string (decoded))
159 } 159 }
160 } 160 }
161 } 161 }
162 if addedMeta { 162 if addedMeta {
163 c = metadata.NewContext(c, md) 163 c = metadata.NewContext(c, md)
164 } 164 }
165 return c, nil 165 return c, nil
166 } 166 }
OLDNEW
« no previous file with comments | « common/prpc/client.go ('k') | server/prpc/decoding_test.go » ('j') | server/prpc/encoding.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698