mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
Fix upnp verbose logging to show outgoing http requests.
This commit is contained in:
@@ -531,7 +531,14 @@ tr_httpAddBody( tr_http_t * http , const char * fmt , ... )
|
||||
}
|
||||
|
||||
void
|
||||
tr_httpGetRequest( tr_http_t * http, const char ** buf, int * len )
|
||||
tr_httpGetHeaders( tr_http_t * http, const char ** buf, int * len )
|
||||
{
|
||||
*buf = http->header.buf;
|
||||
*len = http->header.used;
|
||||
}
|
||||
|
||||
void
|
||||
tr_httpGetBody( tr_http_t * http, const char ** buf, int * len )
|
||||
{
|
||||
*buf = http->body.buf;
|
||||
*len = http->body.used;
|
||||
|
||||
@@ -65,7 +65,8 @@ tr_http_t * tr_httpClientUrl( int, const char *, ... )
|
||||
/* only add headers or body before first pulse */
|
||||
void tr_httpAddHeader( tr_http_t *, const char *, const char * );
|
||||
void tr_httpAddBody( tr_http_t *, const char *, ... ) PRINTF( 2, 3 );
|
||||
void tr_httpGetRequest( tr_http_t *, const char **, int * );
|
||||
void tr_httpGetHeaders( tr_http_t *, const char **, int * );
|
||||
void tr_httpGetBody( tr_http_t *, const char **, int * );
|
||||
tr_tristate_t tr_httpPulse( tr_http_t *, const char **, int * );
|
||||
char * tr_httpWhatsMyAddress( tr_http_t * );
|
||||
void tr_httpClose( tr_http_t * );
|
||||
|
||||
+19
-17
@@ -848,29 +848,14 @@ devicePulse( tr_upnp_device_t * dev, int port )
|
||||
static tr_http_t *
|
||||
makeHttp( int method, const char * host, int port, const char * path )
|
||||
{
|
||||
tr_http_t * ret;
|
||||
#ifdef VERBOSE_LOG
|
||||
const char * body;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
if( tr_httpIsUrl( path, -1 ) )
|
||||
{
|
||||
ret = tr_httpClientUrl( method, "%s", path );
|
||||
return tr_httpClientUrl( method, "%s", path );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = tr_httpClient( method, host, port, "%s", path );
|
||||
return tr_httpClient( method, host, port, "%s", path );
|
||||
}
|
||||
|
||||
#ifdef VERBOSE_LOG
|
||||
tr_httpGetRequest( ret, &body, &len );
|
||||
fprintf( vlog, "send http message, %i bytes:\n", len );
|
||||
fwrite( body, 1, len, vlog );
|
||||
fputs( "\n\n", vlog );
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static tr_http_t *
|
||||
@@ -879,6 +864,10 @@ devicePulseGetHttp( tr_upnp_device_t * dev )
|
||||
tr_http_t * ret;
|
||||
char numstr[6];
|
||||
const char * type;
|
||||
#ifdef VERBOSE_LOG
|
||||
const char * body;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
ret = NULL;
|
||||
switch( dev->state )
|
||||
@@ -940,6 +929,19 @@ devicePulseGetHttp( tr_upnp_device_t * dev )
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE_LOG
|
||||
if( NULL != ret )
|
||||
{
|
||||
tr_httpGetHeaders( ret, &body, &len );
|
||||
fprintf( vlog, "send http message, %i bytes (headers):\n", len );
|
||||
fwrite( body, 1, len, vlog );
|
||||
tr_httpGetBody( ret, &body, &len );
|
||||
fprintf( vlog, "\n\nsend http message, %i bytes (body):\n", len );
|
||||
fwrite( body, 1, len, vlog );
|
||||
fputs( "\n\n", vlog );
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user