spdy_http_utils.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 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#ifndef NET_SPDY_SPDY_HTTP_UTILS_H_
6#define NET_SPDY_SPDY_HTTP_UTILS_H_
7
8#include "googleurl/src/gurl.h"
9#include "net/base/net_export.h"
10#include "net/base/request_priority.h"
11#include "net/spdy/spdy_framer.h"
12#include "net/spdy/spdy_header_block.h"
13
14namespace net {
15
16class HttpResponseInfo;
17struct HttpRequestInfo;
18class HttpRequestHeaders;
19
20// Convert a SpdyHeaderBlock into an HttpResponseInfo.
21// |headers| input parameter with the SpdyHeaderBlock.
22// |response| output parameter for the HttpResponseInfo.
23// Returns true if successfully converted.  False if the SpdyHeaderBlock is
24// incomplete (e.g. missing 'status' or 'version').
25bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers,
26                               int protocol_version,
27                               HttpResponseInfo* response);
28
29// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from
30// HttpRequestInfo and HttpRequestHeaders.
31void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
32                                      const HttpRequestHeaders& request_headers,
33                                      SpdyHeaderBlock* headers,
34                                      int protocol_version,
35                                      bool direct);
36
37// Returns the URL associated with the |headers| by assembling the
38// scheme, host and path from the protocol specific keys.
39GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
40                           int protocol_version,
41                           bool pushed);
42
43NET_EXPORT_PRIVATE SpdyPriority ConvertRequestPriorityToSpdyPriority(
44    RequestPriority priority,
45    int protocol_version);
46
47}  // namespace net
48
49#endif  // NET_SPDY_SPDY_HTTP_UTILS_H_
50