You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
669 B
C++
35 lines
669 B
C++
#include "webcc/http_request.h"
|
|
|
|
#include "webcc/logger.h"
|
|
|
|
namespace webcc {
|
|
|
|
bool HttpRequest::Prepare() {
|
|
if (url_.host().empty()) {
|
|
LOG_ERRO("Invalid request: host is missing.");
|
|
return false;
|
|
}
|
|
|
|
std::string target = "/" + url_.path();
|
|
if (!url_.query().empty()) {
|
|
target += "?";
|
|
target += url_.query();
|
|
}
|
|
|
|
start_line_ = method_;
|
|
start_line_ += " ";
|
|
start_line_ += target;
|
|
start_line_ += " HTTP/1.1";
|
|
start_line_ += kCRLF;
|
|
|
|
if (url_.port().empty()) {
|
|
SetHeader(http::headers::kHost, url_.host());
|
|
} else {
|
|
SetHeader(http::headers::kHost, url_.host() + ":" + url_.port());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace webcc
|