Skip to content

Commit b59dcc5

Browse files
committed
Progress: Client Constructor Test now Builds!
After some re-modeling of the internal implementation of the response object as well as the interface used for initializing the promises, now the client constructor test finally builds! This means most (not all) of the request and response methods required just to instantiate an HTTP client instance is ready for the linking. Much more work to be done to: 1) Re-work and simplify the other tests. 2) Mock the delegates and remove reliance on actual external testing that needs a network connection. 3) Make the request and response objects actually work. This is a tall order just because of the sheer amount of code required to make this happen. 4) Make the request and response objects more efficient in its use of memory and synchronization primitives. I have doubts on the efficiency and effectiveness of using futures for the data but this seems to be the most straight-forward approach for the meantime. Sounds like a lot of work to do but hopefully it's not as hard as it reads.
1 parent dfdcaa8 commit b59dcc5

File tree

6 files changed

+66
-77
lines changed

6 files changed

+66
-77
lines changed

boost/network/protocol/http/client/connection/async_normal.ipp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this<http_async_c
8686

8787
void init_response(response &r) {
8888
impl::setter_access accessor;
89-
this->source_promise = accessor.get_source_promise(r);
90-
this->destination_promise = accessor.get_destination_promise(r);
91-
this->headers_promise = accessor.get_headers_promise(r);
92-
this->body_promise = accessor.get_body_promise(r);
93-
this->version_promise = accessor.get_version_promise(r);
94-
this->status_promise = accessor.get_status_promise(r);
95-
this->status_message_promise = accessor.get_status_message_promise(r);
89+
accessor.set_source_promise(r, this->source_promise);
90+
accessor.set_destination_promise(r, this->destination_promise);
91+
accessor.set_headers_promise(r, this->headers_promise);
92+
accessor.set_body_promise(r, this->body_promise);
93+
accessor.set_version_promise(r, this->version_promise);
94+
accessor.set_status_message_promise(r, this->status_message_promise);
9695
}
9796

9897
void set_errors(boost::system::error_code const & ec) {
@@ -392,16 +391,16 @@ struct http_async_connection_pimpl : boost::enable_shared_from_this<http_async_c
392391
this->destination_promise.set_exception(boost::copy_exception(error));
393392
switch (state) {
394393
case version:
395-
// this->version_promise.set_exception(boost::copy_exception(error));
394+
this->version_promise.set_exception(boost::copy_exception(error));
396395
case status:
397-
// this->status_promise.set_exception(boost::copy_exception(error));
396+
this->status_promise.set_exception(boost::copy_exception(error));
398397
case status_message:
399-
// this->status_message_promise.set_exception(boost::copy_exception(error));
398+
this->status_message_promise.set_exception(boost::copy_exception(error));
400399
case headers:
401-
// this->headers_promise.set_exception(boost::copy_exception(error));
400+
this->headers_promise.set_exception(boost::copy_exception(error));
402401
case body:
403-
// this->body_promise.set_exception(boost::copy_exception(error));
404-
// break;
402+
this->body_promise.set_exception(boost::copy_exception(error));
403+
break;
405404
default:
406405
BOOST_ASSERT(false && "Bug, report this to the developers!");
407406
}

boost/network/protocol/http/impl/access.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ struct response;
1616
namespace impl {
1717

1818
struct setter_access {
19-
promise<std::string> get_version_promise(response &r);
20-
promise<boost::uint16_t> get_status_promise(response &r);
21-
promise<std::string> get_status_message_promise(response &r);
22-
promise<std::multimap<std::string, std::string> > get_headers_promise(response &r);
23-
promise<std::string> get_source_promise(response &r);
24-
promise<std::string> get_destination_promise(response &r);
25-
promise<std::string> get_body_promise(response &r);
19+
void set_version_promise(response &r, promise<std::string> &p);
20+
void set_status_promise(response &r, promise<boost::uint16_t> &p);
21+
void set_status_message_promise(response &r, promise<std::string>&p);
22+
void set_headers_promise(response &r, promise<std::multimap<std::string, std::string> > &p);
23+
void set_source_promise(response &r, promise<std::string> &p);
24+
void set_destination_promise(response &r, promise<std::string> &p);
25+
void set_body_promise(response &r, promise<std::string> &p);
2626
};
2727

2828
} // namespace impl

boost/network/protocol/http/impl/access.ipp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55

66
namespace boost { namespace network { namespace http { namespace impl {
77

8-
promise<std::string> setter_access::get_version_promise(response &r) {
9-
return r.get_version_promise();
8+
void setter_access::set_version_promise(response &r, promise<std::string> &p) {
9+
return r.set_version_promise(p);
1010
}
1111

12-
promise<boost::uint16_t> setter_access::get_status_promise(response &r) {
13-
return r.get_status_promise();
12+
void setter_access::set_status_promise(response &r, promise<boost::uint16_t> &p) {
13+
return r.set_status_promise(p);
1414
}
1515

16-
promise<std::string> setter_access::get_status_message_promise(response &r) {
17-
return r.get_status_message_promise();
16+
void setter_access::set_status_message_promise(response &r, promise<std::string> &p) {
17+
return r.set_status_message_promise(p);
1818
}
1919

20-
promise<std::multimap<std::string, std::string> >
21-
setter_access::get_headers_promise(response &r) {
22-
return r.get_headers_promise();
20+
void
21+
setter_access::set_headers_promise(response &r, promise<std::multimap<std::string, std::string> > &p) {
22+
return r.set_headers_promise(p);
2323
}
2424

25-
promise<std::string> setter_access::get_source_promise(response &r) {
26-
return r.get_source_promise();
25+
void setter_access::set_source_promise(response &r, promise<std::string> &p) {
26+
return r.set_source_promise(p);
2727
}
2828

29-
promise<std::string> setter_access::get_destination_promise(response &r) {
30-
return r.get_destination_promise();
29+
void setter_access::set_destination_promise(response &r, promise<std::string> &p) {
30+
return r.set_destination_promise(p);
3131
}
3232

33-
promise<std::string> setter_access::get_body_promise(response &r) {
34-
return r.get_body_promise();
33+
void setter_access::set_body_promise(response &r, promise<std::string> &p) {
34+
return r.set_body_promise(p);
3535
}
3636

3737
} // namespace impl

boost/network/protocol/http/request/request_base.ipp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ namespace boost { namespace network { namespace http {
1414
request_base::~request_base() {
1515
// default implementation, only required for linking.
1616
}
17+
18+
request_storage_base::~request_storage_base() {
19+
// default implementation, only required for linking.
20+
}
1721

1822
} /* http */
1923

boost/network/protocol/http/response/response.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ struct response : response_base {
6060
friend class impl::setter_access; // Hide access through accessor class.
6161
// These methods are unique to the response type which will allow for creating
6262
// promises that can be set appropriately.
63-
promise<std::string> get_version_promise();
64-
promise<boost::uint16_t> get_status_promise();
65-
promise<std::string> get_status_message_promise();
66-
promise<std::multimap<std::string, std::string> > get_headers_promise();
67-
promise<std::string> get_source_promise();
68-
promise<std::string> get_destination_promise();
69-
promise<std::string> get_body_promise();
63+
void set_version_promise(promise<std::string>&);
64+
void set_status_promise(promise<boost::uint16_t>&);
65+
void set_status_message_promise(promise<std::string>&);
66+
void set_headers_promise(promise<std::multimap<std::string, std::string> >&);
67+
void set_source_promise(promise<std::string>&);
68+
void set_destination_promise(promise<std::string>&);
69+
void set_body_promise(promise<std::string>&);
7070

7171
scoped_ptr<response_pimpl> pimpl_;
7272
};

boost/network/protocol/http/response/response.ipp

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -145,53 +145,39 @@ struct response_pimpl {
145145
}
146146
}
147147

148-
promise<std::string> get_source_promise() {
149-
promise<std::string> promise_;
148+
void set_source_promise(promise<std::string> &promise_) {
150149
unique_future<std::string> tmp_future = promise_.get_future();
151150
source_future_ = move(tmp_future);
152-
return move(promise_);
153151
}
154152

155-
promise<std::string> get_destination_promise() {
156-
promise<std::string> promise_;
153+
void set_destination_promise(promise<std::string> &promise_) {
157154
unique_future<std::string> tmp_future = promise_.get_future();
158155
destination_future_ = move(tmp_future);
159-
return move(promise_);
160156
}
161157

162-
promise<std::multimap<std::string, std::string> > get_headers_promise() {
163-
promise<std::multimap<std::string, std::string> > promise_;
158+
void set_headers_promise(promise<std::multimap<std::string, std::string> > &promise_) {
164159
unique_future<std::multimap<std::string, std::string> > tmp_future = promise_.get_future();
165160
headers_future_ = move(tmp_future);
166-
return promise_;
167161
}
168162

169-
promise<boost::uint16_t> get_status_promise() {
170-
promise<boost::uint16_t> promise_;
163+
void set_status_promise(promise<boost::uint16_t> &promise_) {
171164
unique_future<boost::uint16_t> tmp_future = promise_.get_future();
172165
status_future_ = move(tmp_future);
173-
return promise_;
174166
}
175167

176-
promise<std::string> get_status_message_promise() {
177-
promise<std::string> promise_;
168+
void set_status_message_promise(promise<std::string> &promise_) {
178169
unique_future<std::string> tmp_future = promise_.get_future();
179170
status_message_future_ = move(tmp_future);
180-
return promise_;
181171
}
182172

183-
promise<std::string> get_version_promise() {
184-
promise<std::string> promise_;
173+
void set_version_promise(promise<std::string> &promise_) {
185174
unique_future<std::string> tmp_future = promise_.get_future();
186175
version_future_ = move(tmp_future);
187-
return promise_;
188176
}
189177

190-
promise<std::string> get_body_promise() {
191-
promise<std::string> promise_;
178+
void set_body_promise(promise<std::string> &promise_) {
192179
unique_future<std::string> tmp_future = promise_.get_future();
193180
body_future_ = move(tmp_future);
194-
return promise_;
195181
}
196182

197183
private:
@@ -307,32 +293,32 @@ void response::get_version(std::string &version) const {
307293

308294
response::~response() {}
309295

310-
promise<std::string> response::get_version_promise() {
311-
return pimpl_->get_version_promise();
296+
void response::set_version_promise(promise<std::string> &promise) {
297+
return pimpl_->set_version_promise(promise);
312298
}
313299

314-
promise<boost::uint16_t> response::get_status_promise() {
315-
return pimpl_->get_status_promise();
300+
void response::set_status_promise(promise<boost::uint16_t> &promise) {
301+
return pimpl_->set_status_promise(promise);
316302
}
317303

318-
promise<std::string> response::get_status_message_promise() {
319-
return pimpl_->get_status_message_promise();
304+
void response::set_status_message_promise(promise<std::string> &promise) {
305+
return pimpl_->set_status_message_promise(promise);
320306
}
321307

322-
promise<std::multimap<std::string, std::string> > response::get_headers_promise() {
323-
return pimpl_->get_headers_promise();
308+
void response::set_headers_promise(promise<std::multimap<std::string, std::string> > &promise) {
309+
return pimpl_->set_headers_promise(promise);
324310
}
325311

326-
promise<std::string> response::get_source_promise() {
327-
return pimpl_->get_source_promise();
312+
void response::set_source_promise(promise<std::string> &promise) {
313+
return pimpl_->set_source_promise(promise);
328314
}
329315

330-
promise<std::string> response::get_destination_promise() {
331-
return pimpl_->get_destination_promise();
316+
void response::set_destination_promise(promise<std::string> &promise) {
317+
return pimpl_->set_destination_promise(promise);
332318
}
333319

334-
promise<std::string> response::get_body_promise() {
335-
return pimpl_->get_body_promise();
320+
void response::set_body_promise(promise<std::string> &promise) {
321+
return pimpl_->set_body_promise(promise);
336322
}
337323

338324
} // namespace http

0 commit comments

Comments
 (0)