Support request and response compression.

This commit is contained in:
Chunting Gu
2019-03-20 17:47:45 +08:00
parent f6c305d266
commit d906470a4a
18 changed files with 250 additions and 100 deletions
+16
View File
@@ -103,6 +103,22 @@ void ListAuthUserFollowers(webcc::HttpClientSession& session,
}
}
void CreateAuthorization(webcc::HttpClientSession& session,
const std::string& auth) {
try {
std::string data = "{'note': 'Webcc test', 'scopes': ['public_repo', 'repo', 'repo:status', 'user']}";
auto r = session.Post(kUrlRoot + "/authorizations", std::move(data), true,
{"Authorization", auth});
std::cout << r->content() << std::endl;
} catch (const webcc::Exception& e) {
std::cout << e.what() << std::endl;
}
}
// -----------------------------------------------------------------------------
int main() {
+7
View File
@@ -98,7 +98,10 @@ void BookListService::Get(const webcc::UrlQuery& /*query*/,
json.append(BookToJson(book));
}
// TODO: Simplify
response->content = JsonToString(json);
response->media_type = webcc::http::media_types::kApplicationJson;
response->charset = "utf-8";
response->status = webcc::http::Status::kOK;
}
@@ -114,6 +117,8 @@ void BookListService::Post(const std::string& request_content,
json["id"] = id;
response->content = JsonToString(json);
response->media_type = webcc::http::media_types::kApplicationJson;
response->charset = "utf-8";
response->status = webcc::http::Status::kCreated;
} else {
// Invalid JSON
@@ -144,6 +149,8 @@ void BookDetailService::Get(const webcc::UrlMatches& url_matches,
}
response->content = BookToJsonString(book);
response->media_type = webcc::http::media_types::kApplicationJson;
response->charset = "utf-8";
response->status = webcc::http::Status::kOK;
}