15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NET_SPDY_SPDY_HTTP_UTILS_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NET_SPDY_SPDY_HTTP_UTILS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/net_export.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/request_priority.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/spdy/spdy_framer.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/spdy/spdy_header_block.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/spdy/spdy_protocol.h"
137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HttpResponseInfo;
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct HttpRequestInfo;
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HttpRequestHeaders;
20116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass HttpResponseHeaders;
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Convert a SpdyHeaderBlock into an HttpResponseInfo.
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |headers| input parameter with the SpdyHeaderBlock.
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |response| output parameter for the HttpResponseInfo.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns true if successfully converted.  False if the SpdyHeaderBlock is
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// incomplete (e.g. missing 'status' or 'version').
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers,
28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                               SpdyMajorVersion protocol_version,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               HttpResponseInfo* response);
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Create a SpdyHeaderBlock from HttpRequestInfo and HttpRequestHeaders.
32116680a4aac90f2aa7413d9095a592090648e557Ben MurdochNET_EXPORT_PRIVATE void CreateSpdyHeadersFromHttpRequest(
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const HttpRequestInfo& info,
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const HttpRequestHeaders& request_headers,
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    SpdyMajorVersion protocol_version,
36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    bool direct,
37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    SpdyHeaderBlock* headers);
38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Create a SpdyHeaderBlock from HttpResponseHeaders.
40116680a4aac90f2aa7413d9095a592090648e557Ben MurdochNET_EXPORT_PRIVATE void CreateSpdyHeadersFromHttpResponse(
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    const HttpResponseHeaders& response_headers,
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    SpdyMajorVersion protocol_version,
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    SpdyHeaderBlock* headers);
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns the URL associated with the |headers| by assembling the
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// scheme, host and path from the protocol specific keys.
47f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)NET_EXPORT_PRIVATE GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
48f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                              SpdyMajorVersion protocol_version,
49f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                                              bool pushed);
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NET_EXPORT_PRIVATE SpdyPriority ConvertRequestPriorityToSpdyPriority(
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    RequestPriority priority,
53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    SpdyMajorVersion protocol_version);
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority(
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SpdyPriority priority,
57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    SpdyMajorVersion protocol_version);
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // NET_SPDY_SPDY_HTTP_UTILS_H_
62