зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 92528 "#define FORCE_PR_LOG for http" r=bbaetz, sr=mscott
This commit is contained in:
Родитель
bafde73210
Коммит
68b17feb92
|
@ -24,6 +24,10 @@
|
|||
#ifndef nsHttp_h__
|
||||
#define nsHttp_h__
|
||||
|
||||
#if defined(MOZ_LOGGING)
|
||||
#define FORCE_PR_LOG
|
||||
#endif
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
#include "prtime.h"
|
||||
|
@ -51,6 +55,12 @@ extern PRLogModuleInfo *gHttpLog;
|
|||
#define LOG4(args) PR_LOG(gHttpLog, 4, args)
|
||||
#define LOG(args) LOG4(args)
|
||||
|
||||
#define LOG1_ENABLED() PR_LOG_TEST(gHttpLog, 1)
|
||||
#define LOG2_ENABLED() PR_LOG_TEST(gHttpLog, 2)
|
||||
#define LOG3_ENABLED() PR_LOG_TEST(gHttpLog, 3)
|
||||
#define LOG4_ENABLED() PR_LOG_TEST(gHttpLog, 4)
|
||||
#define LOG_ENABLED() LOG4_ENABLED()
|
||||
|
||||
// http default buffer geometry
|
||||
#define NS_HTTP_SEGMENT_SIZE 4096
|
||||
#define NS_HTTP_BUFFER_SIZE 4096*4 // 16k maximum
|
||||
|
|
|
@ -107,7 +107,7 @@ nsHttpChannel::Init(nsIURI *uri,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
LOG(("nsHttpChannel::Init [this=%x]\n"));
|
||||
LOG(("nsHttpChannel::Init [this=%x]\n", this));
|
||||
|
||||
NS_PRECONDITION(uri, "null uri");
|
||||
|
||||
|
@ -1292,8 +1292,6 @@ nsHttpChannel::GetCredentials(const char *challenges,
|
|||
getter_Copies(result));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
LOG(("generated creds: %s\n", result.get()));
|
||||
|
||||
creds.Assign(result);
|
||||
|
||||
// store these credentials in the cache. we do this even though we don't
|
||||
|
@ -1511,7 +1509,7 @@ nsHttpChannel::AddAuthorizationHeaders()
|
|||
mConnectionInfo->ProxyPort(),
|
||||
nsnull, realm, creds);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG(("adding Proxy_Authorization [creds=%s]\n", creds.get()));
|
||||
LOG(("adding Proxy-Authorization request header\n"));
|
||||
mRequestHead.SetHeader(nsHttp::Proxy_Authorization, creds.get());
|
||||
}
|
||||
}
|
||||
|
@ -1527,7 +1525,7 @@ nsHttpChannel::AddAuthorizationHeaders()
|
|||
realm,
|
||||
creds);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG(("adding Authorization [creds=%s]\n", creds.get()));
|
||||
LOG(("adding Authorization request header\n"));
|
||||
mRequestHead.SetHeader(nsHttp::Authorization, creds.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,24 @@ LocateHttpStart(char *buf, PRUint32 len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
static void
|
||||
LogHeaders(const char *lines)
|
||||
{
|
||||
nsCAutoString buf;
|
||||
char *p;
|
||||
while ((p = PL_strstr(lines, "\r\n")) != nsnull) {
|
||||
buf.Assign(lines, p - lines);
|
||||
if (PL_strcasestr(buf.get(), "authorization: ") != nsnull) {
|
||||
char *p = PL_strchr(PL_strchr(buf.get(), ' ')+1, ' ');
|
||||
while (*++p) *p = '*';
|
||||
}
|
||||
LOG2((" %s\n", buf.get()));
|
||||
lines = p + 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpTransaction <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -138,7 +156,13 @@ nsHttpTransaction::SetupRequest(nsHttpRequestHead *requestHead,
|
|||
mReqHeaderBuf.SetLength(0);
|
||||
requestHead->Flatten(mReqHeaderBuf);
|
||||
|
||||
LOG2(("http request [\n%s]\n", mReqHeaderBuf.get()));
|
||||
#if defined(PR_LOGGING)
|
||||
if (LOG2_ENABLED()) {
|
||||
LOG2(("http request [\n"));
|
||||
LogHeaders(mReqHeaderBuf.get());
|
||||
LOG2(("]\n"));
|
||||
}
|
||||
#endif
|
||||
|
||||
mReqUploadStream = requestStream;
|
||||
if (!mReqUploadStream)
|
||||
|
@ -458,9 +482,13 @@ nsHttpTransaction::HandleContentStart()
|
|||
|
||||
if (mResponseHead) {
|
||||
#if defined(PR_LOGGING)
|
||||
if (LOG2_ENABLED()) {
|
||||
LOG2(("http response [\n"));
|
||||
nsCAutoString headers;
|
||||
mResponseHead->Flatten(headers, PR_FALSE);
|
||||
LOG2(("http response [\n%s]\n", headers.get()));
|
||||
LogHeaders(headers.get());
|
||||
LOG2(("]\n"));
|
||||
}
|
||||
#endif
|
||||
// notify the connection, give it a chance to cause a reset.
|
||||
PRBool reset = PR_FALSE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче