1010#include < string>
1111#include < vector>
1212#include < utility>
13- #include < network/http/v2/constants.hpp>
14- #include < network/http/v2/message_base.hpp>
15- #include < network/http/v2/client/client_errors.hpp>
13+ #include " network/http/v2/constants.hpp"
14+ #include " network/http/v2/method.hpp"
15+ #include " network/http/v2/client/client_errors.hpp"
16+ #include " network/uri.hpp"
1617#include < boost/range/iterator_range.hpp>
1718#include < boost/range/algorithm/equal.hpp>
1819#include < boost/range/as_literal.hpp>
19- #include < network/uri.hpp>
2020
2121namespace network {
2222namespace http {
@@ -30,8 +30,8 @@ namespace network {
3030
3131public:
3232
33- typedef message_base::string_type string_type;
34- typedef message_base::size_type size_type;
33+ typedef std::string string_type;
34+ typedef std:: size_t size_type;
3535
3636/* *
3737 * \brief Destructor.
@@ -82,11 +82,11 @@ namespace network {
8282if (auto scheme = destination.scheme ()) {
8383if ((!boost::equal (*scheme,boost::as_literal (" http" ))) &&
8484(!boost::equal (*scheme,boost::as_literal (" https" )))) {
85- throw invalid_scheme ( std::string ( std::begin (*scheme), std::end (*scheme)) );
85+ throw invalid_url ( );
8686 }
8787 }
8888else {
89- throw invalid_scheme ( " <none> " );
89+ throw invalid_url ( );
9090 }
9191}
9292
@@ -151,11 +151,11 @@ namespace network {
151151 headers_.clear ();
152152}
153153
154- void set_method (string_type method) {
155- method_ =std::move ( method) ;
154+ void set_method (network::http::v2::method method) {
155+ method_ = method;
156156}
157157
158- string_type method ()const {
158+ network::http::v2::method method ()const {
159159return method_;
160160}
161161
@@ -170,21 +170,18 @@ namespace network {
170170private:
171171
172172uri destination_;
173- string_type method_, version_;
173+ network::http::v2::method method_;
174+ string_type version_;
174175headers_type headers_;
175176std::shared_ptr<byte_source> byte_source_;
176177
177178friend std::ostream &operator << (std::ostream &os,const request &req) {
178- request::string_type path{std::begin (*req.destination_ .path ()),std::end (*req.destination_ .path ())};
179- request::string_type host;
180- host.append (request::string_type{std::begin (*req.destination_ .scheme ()),
181- std::end (*req.destination_ .scheme ())});
182- host.append (" ://" );
183- host.append (request::string_type{std::begin (*req.destination_ .authority ()),
184- std::end (*req.destination_ .authority ())});
185-
186- os << req.method_ <<" " << path <<" HTTP/" << req.version_ <<" \r\n " ;
187- os <<" Host:" << host <<" \r\n " ;
179+ os << req.method_ <<" " << *req.destination_ .path () <<" HTTP/" << req.version_ <<" \r\n " ;
180+ os <<" Host:" ;
181+ os << *req.destination_ .scheme ();
182+ os <<" ://" ;
183+ os << *req.destination_ .authority ();
184+ os <<" \r\n " ;
188185for (auto header : req.headers_ ) {
189186 os << header.first <<" :" << header.second <<" \r\n " ;
190187 }