OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Some code to parse HTTP response headers in the format given by |
| 6 // PPAPI's ppb_url_response. |
| 7 // Once we move the trusted NaCl plugin code into chrome, |
| 8 // we should use the standard net/http/http_response_headers.h code. |
| 9 |
| 10 // Keep this file very light on dependencies so that it is easy |
| 11 // build a unittest for this (see the gyp file). Do not depend on anything |
| 12 // other than the standard libraries. |
| 13 |
| 14 // NOTE when switching over to net/http/http_response_headers.h: |
| 15 // There are differences between the "raw" headers that can be parsed by |
| 16 // net/http/http_response_headers and the headers returned by ppb_url_response. |
| 17 // The ppb_url_response headers are \n delimited, while the |
| 18 // http_response_headers are \0 delimited and end in \0\0. |
| 19 |
| 20 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_ |
| 21 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_ |
| 22 |
| 23 #include <string> |
| 24 #include <utility> |
| 25 #include <vector> |
| 26 |
| 27 #include "native_client/src/include/nacl_macros.h" |
| 28 |
| 29 namespace plugin { |
| 30 |
| 31 class NaClHttpResponseHeaders { |
| 32 public: |
| 33 NaClHttpResponseHeaders(); |
| 34 ~NaClHttpResponseHeaders(); |
| 35 |
| 36 typedef std::pair<std::string, std::string> Entry; |
| 37 |
| 38 // Parse and prepare the headers for use with other methods. |
| 39 // Assumes that the headers are \n delimited, which ppb_url_response gives. |
| 40 // Invalid header lines are skipped. |
| 41 void Parse(const std::string& headers_str); |
| 42 |
| 43 // Return a concatenated string of HTTP caching validators. |
| 44 // E.g., Last-Modified time and ETags. |
| 45 std::string GetCacheValidators(); |
| 46 |
| 47 // Return true if the headers indicate that the data should not be stored. |
| 48 bool CacheControlNoStore(); |
| 49 |
| 50 private: |
| 51 std::vector<Entry> header_entries_; |
| 52 NACL_DISALLOW_COPY_AND_ASSIGN(NaClHttpResponseHeaders); |
| 53 }; |
| 54 |
| 55 } // namespace plugin |
| 56 |
| 57 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_ |
OLD | NEW |