| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 streamserver | 5 package streamserver |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/json" | 9 "encoding/json" |
| 10 "errors" | 10 "errors" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 log.Fields{ | 111 log.Fields{ |
| 112 log.ErrorKey: err, | 112 log.ErrorKey: err, |
| 113 }.Errorf(ctx, "Failed to decode stream description data JSON.") | 113 }.Errorf(ctx, "Failed to decode stream description data JSON.") |
| 114 return nil, err | 114 return nil, err |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Make sure that this consumed the full JSON size that was specified. | 117 // Make sure that this consumed the full JSON size that was specified. |
| 118 // | 118 // |
| 119 // We use a countReader because the 'json' library doesn't give us a way
to | 119 // We use a countReader because the 'json' library doesn't give us a way
to |
| 120 // know how many bytes it consumed when it decoded. | 120 // know how many bytes it consumed when it decoded. |
| 121 » if chr.Count() != frameSize { | 121 » if chr.Count != frameSize { |
| 122 log.Fields{ | 122 log.Fields{ |
| 123 » » » "blockSize": chr.Count(), | 123 » » » "blockSize": chr.Count, |
| 124 "frameSize": frameSize, | 124 "frameSize": frameSize, |
| 125 }.Errorf(ctx, "Stream description block was not fully consumed."
) | 125 }.Errorf(ctx, "Stream description block was not fully consumed."
) |
| 126 return nil, errors.New("handshake: stream description block was
not fully consumed") | 126 return nil, errors.New("handshake: stream description block was
not fully consumed") |
| 127 } | 127 } |
| 128 | 128 |
| 129 return f, nil | 129 return f, nil |
| 130 } | 130 } |
| OLD | NEW |