mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibCore: Silence some aggressive CSocket and CHttpJob debug spam
This commit is contained in:
parent
ac215ca601
commit
6b71250d1a
2 changed files with 19 additions and 2 deletions
|
@ -5,19 +5,22 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
//#define CHTTPJOB_DEBUG
|
||||||
#define CHTTPJOB_DEBUG
|
|
||||||
|
|
||||||
static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding)
|
static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding)
|
||||||
{
|
{
|
||||||
|
#ifdef CHTTPJOB_DEBUG
|
||||||
dbg() << "CHttpJob::handle_content_encoding: buf has content_encoding = " << content_encoding;
|
dbg() << "CHttpJob::handle_content_encoding: buf has content_encoding = " << content_encoding;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (content_encoding == "gzip") {
|
if (content_encoding == "gzip") {
|
||||||
if (!CGzip::is_compressed(buf)) {
|
if (!CGzip::is_compressed(buf)) {
|
||||||
dbg() << "CHttpJob::handle_content_encoding: buf is not gzip compressed!";
|
dbg() << "CHttpJob::handle_content_encoding: buf is not gzip compressed!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHTTPJOB_DEBUG
|
||||||
dbg() << "CHttpJob::handle_content_encoding: buf is gzip compressed!";
|
dbg() << "CHttpJob::handle_content_encoding: buf is gzip compressed!";
|
||||||
|
#endif
|
||||||
|
|
||||||
auto uncompressed = CGzip::decompress(buf);
|
auto uncompressed = CGzip::decompress(buf);
|
||||||
if (!uncompressed.has_value()) {
|
if (!uncompressed.has_value()) {
|
||||||
|
@ -25,9 +28,11 @@ static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& c
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHTTPJOB_DEBUG
|
||||||
dbg() << "CHttpJob::handle_content_encoding: Gzip::decompress() successful.\n"
|
dbg() << "CHttpJob::handle_content_encoding: Gzip::decompress() successful.\n"
|
||||||
<< " Input size = " << buf.size() << "\n"
|
<< " Input size = " << buf.size() << "\n"
|
||||||
<< " Output size = " << uncompressed.value().size();
|
<< " Output size = " << uncompressed.value().size();
|
||||||
|
#endif
|
||||||
|
|
||||||
return uncompressed.value();
|
return uncompressed.value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,9 @@ bool CSocket::connect(const String& hostname, int port)
|
||||||
}
|
}
|
||||||
|
|
||||||
IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
|
IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << "CSocket::connect: Resolved '" << hostname << "' to " << host_address;
|
dbg() << "CSocket::connect: Resolved '" << hostname << "' to " << host_address;
|
||||||
|
#endif
|
||||||
return connect(host_address, port);
|
return connect(host_address, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +51,9 @@ bool CSocket::connect(const CSocketAddress& address, int port)
|
||||||
{
|
{
|
||||||
ASSERT(!is_connected());
|
ASSERT(!is_connected());
|
||||||
ASSERT(address.type() == CSocketAddress::Type::IPv4);
|
ASSERT(address.type() == CSocketAddress::Type::IPv4);
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << *this << " connecting to " << address << "...";
|
dbg() << *this << " connecting to " << address << "...";
|
||||||
|
#endif
|
||||||
|
|
||||||
ASSERT(port > 0 && port <= 65535);
|
ASSERT(port > 0 && port <= 65535);
|
||||||
|
|
||||||
|
@ -70,7 +74,9 @@ bool CSocket::connect(const CSocketAddress& address)
|
||||||
{
|
{
|
||||||
ASSERT(!is_connected());
|
ASSERT(!is_connected());
|
||||||
ASSERT(address.type() == CSocketAddress::Type::Local);
|
ASSERT(address.type() == CSocketAddress::Type::Local);
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << *this << " connecting to " << address << "...";
|
dbg() << *this << " connecting to " << address << "...";
|
||||||
|
#endif
|
||||||
|
|
||||||
sockaddr_un saddr;
|
sockaddr_un saddr;
|
||||||
saddr.sun_family = AF_LOCAL;
|
saddr.sun_family = AF_LOCAL;
|
||||||
|
@ -84,10 +90,14 @@ bool CSocket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
|
||||||
int rc = ::connect(fd(), addr, addrlen);
|
int rc = ::connect(fd(), addr, addrlen);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (errno == EINPROGRESS) {
|
if (errno == EINPROGRESS) {
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << *this << " connection in progress (EINPROGRESS)";
|
dbg() << *this << " connection in progress (EINPROGRESS)";
|
||||||
|
#endif
|
||||||
m_notifier = CNotifier::construct(fd(), CNotifier::Event::Write, this);
|
m_notifier = CNotifier::construct(fd(), CNotifier::Event::Write, this);
|
||||||
m_notifier->on_ready_to_write = [this] {
|
m_notifier->on_ready_to_write = [this] {
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << *this << " connected!";
|
dbg() << *this << " connected!";
|
||||||
|
#endif
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
ensure_read_notifier();
|
ensure_read_notifier();
|
||||||
m_notifier->set_event_mask(CNotifier::Event::None);
|
m_notifier->set_event_mask(CNotifier::Event::None);
|
||||||
|
@ -99,7 +109,9 @@ bool CSocket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
|
||||||
perror("CSocket::common_connect: connect");
|
perror("CSocket::common_connect: connect");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef CSOCKET_DEBUG
|
||||||
dbg() << *this << " connected ok!";
|
dbg() << *this << " connected ok!";
|
||||||
|
#endif
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
ensure_read_notifier();
|
ensure_read_notifier();
|
||||||
if (on_connected)
|
if (on_connected)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue