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