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
3 // found in the LICENSE file.
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.
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.
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.
20 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_
21 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_
27 #include "native_client/src/include/nacl_macros.h"
31 class NaClHttpResponseHeaders {
33 NaClHttpResponseHeaders();
34 ~NaClHttpResponseHeaders();
36 typedef std::pair<std::string, std::string> Entry;
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);
43 // Get the value of the header named |name|
44 std::string GetHeader(const std::string& name);
46 // Return a concatenated string of HTTP caching validators.
47 // E.g., Last-Modified time and ETags.
48 std::string GetCacheValidators();
50 // Return true if the headers indicate that the data should not be stored.
51 bool CacheControlNoStore();
54 std::vector<Entry> header_entries_;
55 NACL_DISALLOW_COPY_AND_ASSIGN(NaClHttpResponseHeaders);
60 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_