diff --git a/examples/client_basics.cc b/examples/client_basics.cc index 4ab480f..bfe6ee5 100644 --- a/examples/client_basics.cc +++ b/examples/client_basics.cc @@ -8,6 +8,7 @@ int main() { WEBCC_LOG_INIT("", webcc::LOG_CONSOLE); webcc::ClientSession session; + session.Accept("application/json"); webcc::ResponsePtr r; diff --git a/webcc/request_builder.cc b/webcc/request_builder.cc index 8ce4c7a..583ba95 100644 --- a/webcc/request_builder.cc +++ b/webcc/request_builder.cc @@ -22,10 +22,6 @@ RequestPtr RequestBuilder::operator()() { request->SetHeader(std::move(headers_[i - 1]), std::move(headers_[i])); } - if (!accept_.empty()) { - request->SetHeader(headers::kAccept, std::move(accept_)); - } - // If no Keep-Alive, explicitly set `Connection` to "Close". if (!keep_alive_) { request->SetHeader(headers::kConnection, "Close"); diff --git a/webcc/request_builder.h b/webcc/request_builder.h index 5d3c777..b1347d2 100644 --- a/webcc/request_builder.h +++ b/webcc/request_builder.h @@ -117,10 +117,10 @@ public: return *this; } - // Set content types to accept. + // Set (comma separated) content types to accept. + // E.g., "application/json", "text/html, application/xhtml+xml". RequestBuilder& Accept(const std::string& content_types) { - accept_ = content_types; - return *this; + return Header(headers::kAccept, content_types); } RequestBuilder& Body(const std::string& data) { @@ -195,10 +195,6 @@ private: // E.g., "utf-8". std::string charset_; - // Accept content types (could be comma separated multiple types). - // E.g., "application/json", "text/html, application/xhtml+xml". - std::string accept_; - // Files to upload for a POST request. std::vector form_parts_;