Skip to content

Commit 72ea85e

Browse files
committed
Updated constants and message headers.
1 parent f23c827 commit 72ea85e

File tree

4 files changed

+73
-11
lines changed

4 files changed

+73
-11
lines changed

http/src/http/v2/constants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static std::unordered_map<int, std::string> status_message_map() {
3838
status_messages[411] = "Length Required";
3939
status_messages[412] = "Precondition Failed";
4040
status_messages[413] = "Request Entity Too Large";
41-
status_messages[414] = "Request Uri Too Large";
41+
status_messages[414] = "Request Uri Too Long";
4242
status_messages[415] = "Unsupported Media Type";
4343
status_messages[416] = "Request Range Not Satisfiable";
4444
status_messages[417] = "Expectation Failed";

http/src/network/http/v2/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace network {
220220
}
221221

222222
inline
223-
constexpr int request_uri_too_large() {
223+
constexpr int request_uri_too_long() {
224224
return 414;
225225
}
226226

http/src/network/http/v2/headers.hpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (C) 2013 by Glyn Matthews
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#ifndef __NETWORK_HTTP_V2_HEADERS_INC__
7+
#define __NETWORK_HTTP_V2_HEADERS_INC__
8+
9+
#include <network/http/v2/message_base.hpp>
10+
#include <vector>
11+
#include <utility>
12+
#include <map>
13+
#include <string>
14+
#include <ostream>
15+
#include <istream>
16+
17+
namespace network {
18+
namespace http {
19+
namespace v2 {
20+
21+
struct header {
22+
typedef std::string string-type;
23+
typedef boost::string_ref string_view;
24+
string_type name, value;
25+
};
26+
27+
class headers {
28+
29+
typedef header::string_type string-type;
30+
typedef boost::string_ref string_view;
31+
typedef std::map<string_type, string_type> map_type;
32+
33+
public:
34+
35+
typedef map_type::value_type_type value_type;
36+
typedef map_type::key_type key_type;
37+
typedef map_type::mapped_type mapped_type;
38+
typedef map_type::allocator_type allocator_type;
39+
typedef map_type::iterator iterator;
40+
typedef map_type::const_iterator const_iterator;
41+
typedef map_type::reverse_iterator reverse_iterator;
42+
typedef map_type::const_reverse_iterator const_reverse_iterator;
43+
typedef map_type::size_type size_type;
44+
typedef map_type::difference_type difference_type;
45+
typedef map_type::pointer pointer;
46+
typedef map_type::const_pointer const_pointer;
47+
typedef map_type::reference reference;
48+
typedef map_type::const_reference const_reference;
49+
50+
headers();
51+
52+
};
53+
54+
} // namespace v2
55+
} // namespace http
56+
} // namespace network
57+
58+
#endif // __NETWORK_HTTP_V2_HEADERS_INC__

http/src/network/http/v2/message_base.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <network/config.hpp>
1010
#include <network/uri.hpp>
11+
#include <network/http/v2/headers.hpp>
12+
#include <boost/utility/string_ref.hpp>
1113
#include <string>
1214
#include <functional>
1315

@@ -18,8 +20,9 @@ namespace network {
1820

1921
public:
2022

21-
typedef std::string string_type;
23+
typedef headers::string_type string_type;
2224
typedef string_type::size_type size_type;
25+
typedef boost::string_ref string_view;
2326

2427
message_base() NETWORK_DEFAULTED_FUNCTION;
2528
message_base(const message_base &) NETWORK_DELETED_FUNCTION;
@@ -36,14 +39,15 @@ namespace network {
3639
virtual void append_body(std::string data) = 0;
3740

3841
// Accessors
39-
virtual string_type destination() const = 0;
40-
virtual string_type source() = 0;
41-
virtual string_type headers(std::function<void (string_type, string_type)> inserter) const = 0;
42-
virtual string_type headers(std::function<bool (string_type, string_type)> predicate,
43-
std::function<void (string_type, string_type)> inserter) const = 0;
44-
virtual string_type body() const = 0;
45-
virtual void body(std::function<void (string_type::const_iterator, size_type)> chunk_reader,
46-
size_type size) = 0;
42+
virtual string_type get_destination() const = 0;
43+
virtual string_type get_source() = 0;
44+
virtual void get_headers(std::function<void (string_type, string_type)> inserter) const = 0;
45+
virtual void get_headers(std::function<bool (string_type, string_type)> predicate,
46+
std::function<void (string_type, string_type)> inserter) const = 0;
47+
virtual header get_header(std::string header) = 0;
48+
virtual string_type get_body() const = 0;
49+
//virtual void get_body(std::function<void (string_type::const_iterator, size_type)> chunk_reader,
50+
// size_type size) const = 0;
4751

4852
};
4953
} // namespace v2

0 commit comments

Comments
 (0)