OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 struct { | 188 struct { |
189 const char* method_name; | 189 const char* method_name; |
190 size_t method_name_len; | 190 size_t method_name_len; |
191 RequestMethod id; | 191 RequestMethod id; |
192 } supported_methods[] = { | 192 } supported_methods[] = { |
193 { "GET", 3, GET }, | 193 { "GET", 3, GET }, |
194 { "POST", 4, POST }, | 194 { "POST", 4, POST }, |
195 { "OPTIONS", 7, OPTIONS }, | 195 { "OPTIONS", 7, OPTIONS }, |
196 }; | 196 }; |
197 | 197 |
198 const char* path = NULL; | 198 const char* path = nullptr; |
199 for (size_t i = 0; i < ARRAYSIZE(supported_methods); ++i) { | 199 for (size_t i = 0; i < ARRAYSIZE(supported_methods); ++i) { |
200 if (len > supported_methods[i].method_name_len && | 200 if (len > supported_methods[i].method_name_len && |
201 isspace(begin[supported_methods[i].method_name_len]) && | 201 isspace(begin[supported_methods[i].method_name_len]) && |
202 strncmp(begin, supported_methods[i].method_name, | 202 strncmp(begin, supported_methods[i].method_name, |
203 supported_methods[i].method_name_len) == 0) { | 203 supported_methods[i].method_name_len) == 0) { |
204 method_ = supported_methods[i].id; | 204 method_ = supported_methods[i].id; |
205 path = begin + supported_methods[i].method_name_len; | 205 path = begin + supported_methods[i].method_name_len; |
206 break; | 206 break; |
207 } | 207 } |
208 } | 208 } |
(...skipping 28 matching lines...) Expand all Loading... |
237 while (headers[0] == ' ') | 237 while (headers[0] == ' ') |
238 ++headers; | 238 ++headers; |
239 content_length_ = atoi(headers); | 239 content_length_ = atoi(headers); |
240 } else if ((headers + ARRAYSIZE(kContentType)) < end && | 240 } else if ((headers + ARRAYSIZE(kContentType)) < end && |
241 strncmp(headers, kContentType, | 241 strncmp(headers, kContentType, |
242 ARRAYSIZE(kContentType) - 1) == 0) { | 242 ARRAYSIZE(kContentType) - 1) == 0) { |
243 headers += ARRAYSIZE(kContentType) - 1; | 243 headers += ARRAYSIZE(kContentType) - 1; |
244 while (headers[0] == ' ') | 244 while (headers[0] == ' ') |
245 ++headers; | 245 ++headers; |
246 const char* type_end = strstr(headers, "\r\n"); | 246 const char* type_end = strstr(headers, "\r\n"); |
247 if (type_end == NULL) | 247 if (type_end == nullptr) |
248 type_end = end; | 248 type_end = end; |
249 content_type_.assign(headers, type_end); | 249 content_type_.assign(headers, type_end); |
250 } | 250 } |
251 } else { | 251 } else { |
252 ++headers; | 252 ++headers; |
253 } | 253 } |
254 headers = strstr(headers, "\r\n"); | 254 headers = strstr(headers, "\r\n"); |
255 if (headers) | 255 if (headers) |
256 headers += 2; | 256 headers += 2; |
257 } | 257 } |
(...skipping 22 matching lines...) Expand all Loading... |
280 return listen(socket_, 5) != SOCKET_ERROR; | 280 return listen(socket_, 5) != SOCKET_ERROR; |
281 } | 281 } |
282 | 282 |
283 DataSocket* ListeningSocket::Accept() const { | 283 DataSocket* ListeningSocket::Accept() const { |
284 assert(valid()); | 284 assert(valid()); |
285 struct sockaddr_in addr = {0}; | 285 struct sockaddr_in addr = {0}; |
286 socklen_t size = sizeof(addr); | 286 socklen_t size = sizeof(addr); |
287 NativeSocket client = | 287 NativeSocket client = |
288 accept(socket_, reinterpret_cast<sockaddr*>(&addr), &size); | 288 accept(socket_, reinterpret_cast<sockaddr*>(&addr), &size); |
289 if (client == INVALID_SOCKET) | 289 if (client == INVALID_SOCKET) |
290 return NULL; | 290 return nullptr; |
291 | 291 |
292 return new DataSocket(client); | 292 return new DataSocket(client); |
293 } | 293 } |
OLD | NEW |