| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "nacl_io/httpfs/http_fs_node.h" | 5 #include "nacl_io/httpfs/http_fs_node.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 | 11 |
| 12 #include <ppapi/c/pp_errors.h> | 12 #include <ppapi/c/pp_errors.h> |
| 13 | 13 |
| 14 #include "nacl_io/httpfs/http_fs.h" | 14 #include "nacl_io/httpfs/http_fs.h" |
| 15 #include "nacl_io/kernel_handle.h" | 15 #include "nacl_io/kernel_handle.h" |
| 16 #include "nacl_io/osinttypes.h" | 16 #include "nacl_io/osinttypes.h" |
| 17 #include "nacl_io/statuscode.h" |
| 17 | 18 |
| 18 #if defined(WIN32) | 19 #if defined(WIN32) |
| 19 #define snprintf _snprintf | 20 #define snprintf _snprintf |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace nacl_io { | 23 namespace nacl_io { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // If we're attempting to read a partial request, but the server returns a full | 27 // If we're attempting to read a partial request, but the server returns a full |
| 27 // request, we need to read all of the data up to the start of our partial | 28 // request, we need to read all of the data up to the start of our partial |
| 28 // request into a dummy buffer. This is the maximum size of that buffer. | 29 // request into a dummy buffer. This is the maximum size of that buffer. |
| 29 const int MAX_READ_BUFFER_SIZE = 64 * 1024; | 30 const int MAX_READ_BUFFER_SIZE = 64 * 1024; |
| 30 const int32_t STATUSCODE_OK = 200; | |
| 31 const int32_t STATUSCODE_PARTIAL_CONTENT = 206; | |
| 32 const int32_t STATUSCODE_FORBIDDEN = 403; | |
| 33 const int32_t STATUSCODE_NOT_FOUND = 404; | |
| 34 const int32_t STATUSCODE_REQUESTED_RANGE_NOT_SATISFIABLE = 416; | |
| 35 | 31 |
| 36 StringMap_t ParseHeaders(const char* headers, int32_t headers_length) { | 32 StringMap_t ParseHeaders(const char* headers, int32_t headers_length) { |
| 37 enum State { | 33 enum State { |
| 38 FINDING_KEY, | 34 FINDING_KEY, |
| 39 SKIPPING_WHITESPACE, | 35 SKIPPING_WHITESPACE, |
| 40 FINDING_VALUE, | 36 FINDING_VALUE, |
| 41 }; | 37 }; |
| 42 | 38 |
| 43 StringMap_t result; | 39 StringMap_t result; |
| 44 std::string key; | 40 std::string key; |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 assert(bytes_read <= bytes_to_read); | 671 assert(bytes_read <= bytes_to_read); |
| 676 bytes_to_read -= bytes_read; | 672 bytes_to_read -= bytes_read; |
| 677 out_buffer += bytes_read; | 673 out_buffer += bytes_read; |
| 678 } | 674 } |
| 679 | 675 |
| 680 *out_bytes = count; | 676 *out_bytes = count; |
| 681 return 0; | 677 return 0; |
| 682 } | 678 } |
| 683 | 679 |
| 684 } // namespace nacl_io | 680 } // namespace nacl_io |
| OLD | NEW |