Permalink
Browse files

For debugging: add env. variable MS_HTTP_HEADER that can be set to NO…

… in the non-MOD_WMS_ENABLED mode to avoid emitting HTTP headers
  • Loading branch information...
rouault committed Oct 2, 2014
1 parent 41067b4 commit fba3bec786ba208c31c0ecebba0a64e87a8d9209
Showing with 17 additions and 5 deletions.
  1. +17 −5 mapio.c
View
22 mapio.c
@@ -46,6 +46,7 @@
static int is_msIO_initialized = MS_FALSE;
static int is_msIO_header_enabled = MS_TRUE;
typedef struct msIOContextGroup_t {
msIOContext stdin_context;
@@ -212,9 +213,11 @@ void msIO_setHeader (const char *header, const char* value, ...)
}
} else {
#endif // MOD_WMS_ENABLED
msIO_fprintf(stdout,"%s: ",header);
msIO_vfprintf(stdout,value,args);
msIO_fprintf(stdout,"\r\n");
if( is_msIO_header_enabled ) {
msIO_fprintf(stdout,"%s: ",header);
msIO_vfprintf(stdout,value,args);
msIO_fprintf(stdout,"\r\n");
}
#ifdef MOD_WMS_ENABLED
}
#endif
@@ -227,8 +230,10 @@ void msIO_sendHeaders ()
msIOContext *ioctx = msIO_getHandler (stdout);
if(ioctx && !strcmp(ioctx->label,"apache")) return;
#endif // !MOD_WMS_ENABLED
msIO_printf ("\r\n");
fflush (stdout);
if( is_msIO_header_enabled ) {
msIO_printf ("\r\n");
fflush (stdout);
}
}
@@ -518,9 +523,16 @@ static int msIO_stdioWrite( void *cbData, void *data, int byteCount )
static void msIO_Initialize( void )
{
const char* pszStripHTTPHeader;
if( is_msIO_initialized == MS_TRUE )
return;
pszStripHTTPHeader = getenv("MS_HTTP_HEADER");
is_msIO_header_enabled = ( pszStripHTTPHeader == NULL ||
strcasecmp(pszStripHTTPHeader, "YES") == 0 ||
strcasecmp(pszStripHTTPHeader, "ON") == 0 );
default_contexts.stdin_context.label = "stdio";
default_contexts.stdin_context.write_channel = MS_FALSE;
default_contexts.stdin_context.readWriteFunc = msIO_stdioRead;

0 comments on commit fba3bec

Please sign in to comment.