Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / ppapi / native_client / src / trusted / plugin / nacl_http_response_headers.h
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.
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   // Get the value of the header named |name|
44   std::string GetHeader(const std::string& name);
45
46   // Return a concatenated string of HTTP caching validators.
47   // E.g., Last-Modified time and ETags.
48   std::string GetCacheValidators();
49
50   // Return true if the headers indicate that the data should not be stored.
51   bool CacheControlNoStore();
52
53  private:
54   std::vector<Entry> header_entries_;
55   NACL_DISALLOW_COPY_AND_ASSIGN(NaClHttpResponseHeaders);
56 };
57
58 }  // namespace plugin
59
60 #endif  // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_NACL_HTTP_RESPONSE_HEADERS_H_