http: Cleanup excessive logging.

This commit is contained in:
Unknown W. Brackets 2021-01-01 08:51:46 -08:00
parent 83644ec1b8
commit c3ddb279f9
4 changed files with 28 additions and 8 deletions

View File

@ -366,6 +366,7 @@ int Client::ReadResponseHeaders(Buffer *readbuf, std::vector<std::string> &respo
if (code_pos != line.npos) {
code = atoi(&line[code_pos]);
} else {
ERROR_LOG(IO, "Code not parse HTTP status code");
return -1;
}
@ -377,6 +378,7 @@ int Client::ReadResponseHeaders(Buffer *readbuf, std::vector<std::string> &respo
}
if (responseHeaders.size() == 0) {
ERROR_LOG(IO, "No HTTP response headers");
return -1;
}

View File

@ -33,7 +33,7 @@ bool RequestHeader::GetParamValue(const char *param_name, std::string *value) co
for (size_t i = 0; i < v.size(); i++) {
std::vector<std::string> parts;
SplitString(v[i], '=', parts);
INFO_LOG(IO, "Param: %s Value: %s", parts[0].c_str(), parts[1].c_str());
DEBUG_LOG(IO, "Param: %s Value: %s", parts[0].c_str(), parts[1].c_str());
if (parts[0] == param_name) {
*value = parts[1];
return true;
@ -121,13 +121,13 @@ int RequestHeader::ParseHttpHeader(const char *buffer) {
if (!strncasecmp(key, "User-Agent", key_len)) {
user_agent = new char[value_len + 1];
memcpy(user_agent, buffer, value_len + 1);
INFO_LOG(IO, "user-agent: %s", user_agent);
VERBOSE_LOG(IO, "user-agent: %s", user_agent);
} else if (!strncasecmp(key, "Referer", key_len)) {
referer = new char[value_len + 1];
memcpy(referer, buffer, value_len + 1);
} else if (!strncasecmp(key, "Content-Length", key_len)) {
content_length = atoi(buffer);
INFO_LOG(IO, "Content-Length: %i", (int)content_length);
VERBOSE_LOG(IO, "Content-Length: %i", (int)content_length);
} else {
std::string key_str(key, key_len);
std::transform(key_str.begin(), key_str.end(), key_str.begin(), tolower);
@ -150,12 +150,12 @@ void RequestHeader::ParseHeaders(net::InputSink *sink) {
line_count++;
if (type == SIMPLE) {
// Done!
INFO_LOG(IO, "Simple: Done parsing http request.");
VERBOSE_LOG(IO, "Simple: Done parsing http request.");
break;
}
}
INFO_LOG(IO, "finished parsing request.");
VERBOSE_LOG(IO, "finished parsing request.");
ok = line_count > 1;
}

View File

@ -54,7 +54,7 @@ Request::Request(int fd)
header_.ParseHeaders(in_);
if (header_.ok) {
INFO_LOG(IO, "The request carried with it %i bytes", (int)header_.content_length);
VERBOSE_LOG(IO, "The request carried with it %i bytes", (int)header_.content_length);
} else {
Close();
}
@ -171,8 +171,13 @@ bool Server::Listen4(int port) {
setsockopt(listener_, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt));
if (bind(listener_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
#if PPSSPP_PLATFORM(WINDOWS)
int err = WSAGetLastError();
#else
int err = errno;
#endif
ERROR_LOG(IO, "Failed to bind to port %d, error=%d - Bailing (ipv4)", port, err);
closesocket(listener_);
ERROR_LOG(IO, "Failed to bind to port %d. Bailing.", port);
return false;
}
@ -216,8 +221,13 @@ bool Server::Listen6(int port, bool ipv6_only) {
setsockopt(listener_, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&opt, sizeof(opt));
if (bind(listener_, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
#if PPSSPP_PLATFORM(WINDOWS)
int err = WSAGetLastError();
#else
int err = errno;
#endif
ERROR_LOG(IO, "Failed to bind to port %d, error=%d - Bailing (ipv6)", port, err);
closesocket(listener_);
ERROR_LOG(IO, "Failed to bind to port %d. Bailing.", port);
return false;
}

View File

@ -385,6 +385,14 @@ void OutputSink::AccountPush(size_t bytes) {
void OutputSink::AccountDrain(int bytes) {
if (bytes < 0) {
#if PPSSPP_PLATFORM(WINDOWS)
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK)
return;
#else
if (errno == EWOULDBLOCK || errno == EAGAIN)
return;
#endif
ERROR_LOG(IO, "Error writing to socket");
return;
}