Skip to content

Commit 4578dfd

Browse files
committed
Finishing requestion_options implementation.
1 parent 7881179 commit 4578dfd

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

boost/network/protocol/http/client/options.ipp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,86 @@ shared_ptr<http::connection_factory> client_options::connection_factory() const
192192
return pimpl->connection_factory();
193193
}
194194

195+
// End of client_options.
196+
197+
class request_options_pimpl {
198+
public:
199+
request_options_pimpl()
200+
: timeout_ms_(30 * 1000)
201+
, max_redirects_(10)
202+
{}
203+
204+
request_options_pimpl *clone() const {
205+
return new (std::nothrow) request_options_pimpl(*this);
206+
}
207+
208+
void timeout(uint64_t milliseconds) {
209+
timeout_ms_ = milliseconds;
210+
}
211+
212+
uint64_t timeout() const {
213+
return timeout_ms_;
214+
}
215+
216+
void max_redirects(int redirects) {
217+
max_redirects_ = redirects;
218+
}
219+
220+
int max_redirects() const {
221+
return max_redirects_;
222+
}
223+
224+
private:
225+
uint64_t timeout_ms_;
226+
int max_redirects_;
227+
228+
request_options_pimpl(request_options_pimpl const &other)
229+
: timeout_ms_(other.timeout_ms_)
230+
, max_redirects_(other.max_redirects_)
231+
{}
232+
233+
request_options_pimpl& operator=(request_options_pimpl); // cannot be assigned.
234+
};
235+
236+
request_options::request_options()
237+
: pimpl(new (std::nothrow) request_options_pimpl)
238+
{}
239+
240+
request_options::request_options(request_options const &other)
241+
: pimpl(other.pimpl->clone())
242+
{}
243+
244+
request_options& request_options::operator=(request_options rhs) {
245+
rhs.swap(*this);
246+
return *this;
247+
}
248+
249+
void request_options::swap(request_options &other) {
250+
std::swap(other.pimpl, this->pimpl);
251+
}
252+
253+
request_options::~request_options() {
254+
delete pimpl;
255+
}
256+
257+
request_options& request_options::timeout(uint64_t milliseconds) {
258+
pimpl->timeout(milliseconds);
259+
return *this;
260+
}
261+
262+
uint64_t request_options::timeout() const {
263+
return pimpl->timeout();
264+
}
265+
266+
request_options& request_options::max_redirects(int redirects) {
267+
pimpl->max_redirects(redirects);
268+
return *this;
269+
}
270+
271+
int request_options::max_redirects() const {
272+
return pimpl->max_redirects();
273+
}
274+
195275
} // namespace http
196276
} // namespace network
197277
} // namespace boost

0 commit comments

Comments
 (0)