blob: e26ee77f1074857eefbae73412cea09725ef0333 [file] [log] [blame]
Alex Vakulenko5298c2c2014-04-21 17:05:51 -07001// Copyright 2014 The Chromium OS 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 BUFFET_HTTP_TRANSPORT_H_
6#define BUFFET_HTTP_TRANSPORT_H_
7
8#include <memory>
9#include <string>
Alex Vakulenko7c3226e2014-05-07 17:35:24 -070010#include <utility>
Alex Vakulenko5298c2c2014-04-21 17:05:51 -070011#include <vector>
12
13#include <base/basictypes.h>
14
Alex Vakulenko7c3226e2014-05-07 17:35:24 -070015#include "buffet/error.h"
16
Alex Vakulenko25445932014-05-08 16:25:45 -070017namespace buffet {
Alex Vakulenko5298c2c2014-04-21 17:05:51 -070018namespace http {
19
20typedef std::vector<std::pair<std::string, std::string>> HeaderList;
21
22class Request;
23class Connection;
24
25///////////////////////////////////////////////////////////////////////////////
26// Transport is a base class for specific implementation of HTTP communication.
27// This class (and its underlying implementation) is used by http::Request and
28// http::Response classes to provide HTTP functionality to the clients.
29///////////////////////////////////////////////////////////////////////////////
30class Transport {
31 public:
32 Transport() = default;
33 virtual ~Transport() = default;
34
35 // Creates a connection object and initializes it with the specified data.
36 // |transport| is a shared pointer to this transport object instance,
37 // used to maintain the object alive as long as the connection exists.
38 virtual std::unique_ptr<Connection> CreateConnection(
39 std::shared_ptr<Transport> transport,
40 const std::string& url,
41 const std::string& method,
42 const HeaderList& headers,
43 const std::string& user_agent,
44 const std::string& referer,
Alex Vakulenko7c3226e2014-05-07 17:35:24 -070045 ErrorPtr* error) = 0;
Alex Vakulenko5298c2c2014-04-21 17:05:51 -070046
47 private:
48 DISALLOW_COPY_AND_ASSIGN(Transport);
49};
50
Alex Vakulenko7c3226e2014-05-07 17:35:24 -070051} // namespace http
Alex Vakulenko25445932014-05-08 16:25:45 -070052} // namespace buffet
Alex Vakulenko5298c2c2014-04-21 17:05:51 -070053
Alex Vakulenko7c3226e2014-05-07 17:35:24 -070054#endif // BUFFET_HTTP_TRANSPORT_H_