почти рабочая авторизация. оказывается сейчас нет payload у запроса, поэтому невозможно распарсить из него json.
This commit is contained in:
@@ -126,9 +126,7 @@ namespace http::server {
|
||||
|
||||
void SslConnection::doWrite() {
|
||||
reply_.headers.push_back({.name = "Server", .value = SERVER_HEADER_VALUE});
|
||||
if (!reply_.content.empty()) {
|
||||
reply_.headers.push_back({.name = "Content-Length", .value = std::to_string(reply_.content.size())});
|
||||
}
|
||||
reply_.headers.push_back({.name = "Content-Length", .value = std::to_string(reply_.content.size())});
|
||||
if (request_.http_version_major == 1) {
|
||||
reply_.headers.push_back({.name = "Connection", .value = "keep-alive"});
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ namespace http::server {
|
||||
const std::string multiple_choices = "HTTP/1.1 300 Multiple Choices\r\n";
|
||||
const std::string moved_permanently = "HTTP/1.1 301 Moved Permanently\r\n";
|
||||
const std::string moved_temporarily = "HTTP/1.1 302 Moved Temporarily\r\n";
|
||||
const std::string see_other_redirect = "HTTP/1.1 303 See Other\r\n";
|
||||
const std::string not_modified = "HTTP/1.1 304 Not Modified\r\n";
|
||||
const std::string bad_request = "HTTP/1.1 400 Bad Request\r\n";
|
||||
const std::string unauthorized = "HTTP/1.1 401 Unauthorized\r\n";
|
||||
@@ -39,6 +40,8 @@ namespace http::server {
|
||||
return boost::asio::buffer(moved_permanently);
|
||||
case status_type::moved_temporarily:
|
||||
return boost::asio::buffer(moved_temporarily);
|
||||
case status_type::see_other_redirect:
|
||||
return boost::asio::buffer(see_other_redirect);
|
||||
case status_type::not_modified:
|
||||
return boost::asio::buffer(not_modified);
|
||||
case status_type::bad_request:
|
||||
@@ -78,7 +81,9 @@ namespace http::server {
|
||||
buffers.push_back(boost::asio::buffer(misc_strings::crlf));
|
||||
}
|
||||
buffers.emplace_back(boost::asio::buffer(misc_strings::crlf));
|
||||
buffers.emplace_back(boost::asio::buffer(content));
|
||||
if (!content.empty()) {
|
||||
buffers.emplace_back(boost::asio::buffer(content));
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
@@ -212,4 +217,11 @@ namespace http::server {
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::text_html)});
|
||||
stock_replies::as_content(status, rep.content);
|
||||
}
|
||||
|
||||
void httpRedirect(Reply &rep, const std::string &location) {
|
||||
rep.status = see_other_redirect;
|
||||
rep.content.clear();
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::text_html)});
|
||||
rep.headers.push_back({.name = "Location", .value = location});
|
||||
}
|
||||
} // namespace http::server
|
||||
|
@@ -16,6 +16,7 @@ namespace http::server {
|
||||
multiple_choices = 300,
|
||||
moved_permanently = 301,
|
||||
moved_temporarily = 302,
|
||||
see_other_redirect = 303,
|
||||
not_modified = 304,
|
||||
bad_request = 400,
|
||||
unauthorized = 401,
|
||||
@@ -46,6 +47,7 @@ namespace http::server {
|
||||
/// Get a stock reply.
|
||||
void stockReply(status_type status, Reply& rep);
|
||||
|
||||
void httpRedirect(Reply& rep, const std::string& location);
|
||||
} // namespace http::Server
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user