OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "services/http_server/http_request_parser.h" | 5 #include "services/http_server/http_request_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 DCHECK(success) << "Malformed Content-Length header's value."; | 132 DCHECK(success) << "Malformed Content-Length header's value."; |
133 } | 133 } |
134 if (declared_content_length == 0) { | 134 if (declared_content_length == 0) { |
135 // No content data, so parsing is finished. | 135 // No content data, so parsing is finished. |
136 state_ = STATE_ACCEPTED; | 136 state_ = STATE_ACCEPTED; |
137 return ACCEPTED; | 137 return ACCEPTED; |
138 } | 138 } |
139 | 139 |
140 // If we ever want to support really large content length (currently pipe max | 140 // If we ever want to support really large content length (currently pipe max |
141 // 256 MB), then we'll have to stream data from parser to handler. | 141 // 256 MB), then we'll have to stream data from parser to handler. |
142 MojoCreateDataPipeOptions options = {sizeof(MojoCreateDataPipeOptions), | 142 MojoCreateDataPipeOptions options = { |
143 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, | 143 sizeof(MojoCreateDataPipeOptions), |
144 1, | 144 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 1, |
145 declared_content_length}; | 145 static_cast<uint32_t>(declared_content_length)}; |
146 MojoResult result = CreateDataPipe( | 146 MojoResult result = CreateDataPipe( |
147 &options, &producer_handle_, &http_request_->body); | 147 &options, &producer_handle_, &http_request_->body); |
148 if (result != MOJO_RESULT_OK) { | 148 if (result != MOJO_RESULT_OK) { |
149 NOTREACHED() << "Couldn't create data pipe of size " | 149 NOTREACHED() << "Couldn't create data pipe of size " |
150 << declared_content_length; | 150 << declared_content_length; |
151 return PARSE_ERROR; | 151 return PARSE_ERROR; |
152 } | 152 } |
153 | 153 |
154 // The request has not yet been parsed yet, content data is still to be | 154 // The request has not yet been parsed yet, content data is still to be |
155 // processed. | 155 // processed. |
(...skipping 25 matching lines...) Expand all Loading... |
181 state_ = STATE_CONTENT; | 181 state_ = STATE_CONTENT; |
182 return WAITING; | 182 return WAITING; |
183 } | 183 } |
184 | 184 |
185 HttpRequestPtr HttpRequestParser::GetRequest() { | 185 HttpRequestPtr HttpRequestParser::GetRequest() { |
186 DCHECK_EQ(STATE_ACCEPTED, state_); | 186 DCHECK_EQ(STATE_ACCEPTED, state_); |
187 return http_request_.Pass(); | 187 return http_request_.Pass(); |
188 } | 188 } |
189 | 189 |
190 } // namespace http_server | 190 } // namespace http_server |
OLD | NEW |