Skip to content

Commit 14431f3

Browse files
committed
DMC-1361: Modify the "ne_davix_logger" function to recognize header messages and propagate them with a higher log verbosity
1 parent 8c822b3 commit 14431f3

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

deps/libneon/src/ne_request.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -880,16 +880,16 @@ static void dump_request(const char *request)
880880

881881
if (davix_get_log_scope() & NE_DBG_HTTPPLAIN) {
882882
/* Display everything mode */
883-
NE_DEBUG(NE_DBG_HTTP, "%s", hdr_debug);
884-
} else if (davix_get_log_scope() & NE_DBG_HTTP) {
883+
NE_DEBUG(NE_DBG_HDR, "%s", hdr_debug);
884+
} else if (davix_get_log_scope() & NE_DBG_HDR) {
885885
/* Blank out the Authorization parameters */
886886
char *reqdebug = ne_strdup(hdr_debug), *pnt = reqdebug;
887887
while ((pnt = strstr(pnt, "Authorization: ")) != NULL) {
888888
for (pnt += 15; *pnt != '\r' && *pnt != '\0'; pnt++) {
889889
*pnt = 'x';
890890
}
891891
}
892-
NE_DEBUG(NE_DBG_HTTP, "%s",reqdebug);
892+
NE_DEBUG(NE_DBG_HDR, "%s",reqdebug);
893893

894894
ne_free(reqdebug);
895895
}
@@ -925,7 +925,7 @@ static int read_status_line(ne_request *req, ne_status *status, int retry)
925925
}
926926

927927
strip_eol(buffer, &ret);
928-
NE_DEBUG(NE_DBG_HTTP, "< %s", buffer);
928+
NE_DEBUG(NE_DBG_HDR, "< %s", buffer);
929929

930930
if (status->reason_phrase) ne_free(status->reason_phrase);
931931
memset(status, 0, sizeof *status);
@@ -1039,7 +1039,7 @@ static int read_message_header(ne_request *req, char *buf, size_t buflen)
10391039
return aborted(req, _("Error reading response headers"), n);
10401040

10411041
strip_eol(buf, &n);
1042-
NE_DEBUG(NE_DBG_HTTP, "< %s", buf);
1042+
NE_DEBUG(NE_DBG_HDR, "< %s", buf);
10431043

10441044
if (n == 0) {
10451045
NE_DEBUG(NE_DBG_CORE, "End of headers.");
@@ -1215,7 +1215,7 @@ int ne_begin_request(ne_request *req)
12151215

12161216
/* Build the request string, and send it */
12171217
data = build_request(req);
1218-
if(davix_get_log_scope() & NE_DBG_HTTP){
1218+
if(davix_get_log_scope() & NE_DBG_HDR){
12191219
dump_request(data->data);
12201220
}
12211221
ret = send_request(req, data);

deps/libneon/src/ne_utils.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,18 @@ int ne_version_match(int major, int minor)
132132
|| (NE_VERSION_MAJOR == 0 && NE_VERSION_MINOR != minor);
133133
}
134134

135+
/// Davix logging function for libneon messages
136+
/// The Header messages are propagated with "VERBOSE" level
137+
/// The rest of the messages are propagated with "TRACE" level
135138
void ne_davix_logger(int scope, const char *msg, ...)
136139
{
137-
if( (davix_get_log_level() >= DAVIX_LOG_DEBUG) && (davix_get_log_scope() & scope) ) {
140+
int filter_level = (scope == DAVIX_LOG_HEADER) ? DAVIX_LOG_VERBOSE : DAVIX_LOG_DEBUG;
141+
int propagate_level = (scope == DAVIX_LOG_HEADER) ? DAVIX_LOG_VERBOSE : DAVIX_LOG_TRACE;
142+
143+
if ((davix_get_log_level() >= filter_level) && (davix_get_log_scope() & scope)) {
138144
va_list va;
139145
va_start(va, msg);
140-
davix_vlogger2(scope, DAVIX_LOG_TRACE, msg, va);
146+
davix_vlogger2(scope, propagate_level, msg, va);
141147
va_end(va);
142148
}
143149
}

deps/libneon/src/ne_utils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ int ne_has_support(int feature);
8383
/* Debugging masks. */
8484
/* Map to DAVIX logging masks. */
8585
#define NE_DBG_SOCKET (DAVIX_LOG_SOCKET ) /* raw socket */
86-
#define NE_DBG_HTTP (DAVIX_LOG_HEADER ) /* HTTP request/response handling */
86+
#define NE_DBG_HDR (DAVIX_LOG_HEADER ) /* HTTP headers */
87+
#define NE_DBG_HTTP (DAVIX_LOG_HTTP ) /* HTTP request/response handling */
8788
#define NE_DBG_XML (DAVIX_LOG_XML ) /* XML parser */
8889
#define NE_DBG_HTTPAUTH (DAVIX_LOG_SSL ) /* HTTP authentication (hiding credentials) */
8990
#define NE_DBG_HTTPPLAIN (DAVIX_LOG_SENSITIVE ) /* plaintext HTTP authentication */

0 commit comments

Comments
 (0)