pike.git
/
src
/
modules
/
_Roxen
/
roxen.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/_Roxen/roxen.c:68:
static void f_hp_exit( struct object *UNUSED(o) ) { if( THP->headers ) free( THP->headers ); THP->headers = NULL; THP->pnt = NULL; THP->hsize = 0; } static void f_hp_feed( INT32 args )
-
/*! @decl array(string|mapping) feed(string data)
+
/*! @decl array(string|mapping) feed(string data
, void|int lower_case
)
*! *! @returns *! @array *! @elem string 0 *! Trailing data. *! @elem string 1 *! First line of request. *! @elem mapping(string:string|array(string)) 2 *! Headers. *! @endarray */ {
-
struct pike_string *str = Pike_sp[-
1
].u.string;
+
struct pike_string *str = Pike_sp[-
args
].u.string;
+
int lower_case = 1;
struct header_buf *hp = THP; int str_len; int tot_slash_n=hp->slash_n, slash_n = hp->tslash_n, spc = hp->spc; unsigned char *pp,*ep; struct svalue *tmp; struct mapping *headers; ptrdiff_t os=0, i, j, l; unsigned char *in;
-
if (args
!
= 1)
+
if
(
!
(
args =
=
1
|| args == 2
)
)
Pike_error("Bad number of arguments to feed().\n");
-
if( TYPEOF(Pike_sp[-
1
]) != PIKE_T_STRING )
+
if( TYPEOF(Pike_sp[-
args
]) != PIKE_T_STRING )
Pike_error("Wrong type of argument to feed()\n");
-
+
if( args == 2 )
+
if( TYPEOF(Pike_sp[-args+1]) == PIKE_T_INT )
+
lower_case = Pike_sp[-args+1].u.integer;
+
else
+
Pike_error("Wrong type of argument to feed()\n");
if( str->size_shift ) Pike_error("Wide string headers not supported\n"); str_len = str->len; while( str_len >= hp->left ) { unsigned char *buf; if( hp->hsize > 512 * 1024 ) Pike_error("Too many headers\n"); hp->hsize += 8192; buf = hp->headers;
pike.git/src/modules/_Roxen/roxen.c:188:
if((in[i] == '\r') && (in[i+1] == '\n')) i++; i++; in += i; l -= i; /* Parse headers. */ for(i = 0; i < l; i++) { if(in[i] > 64 && in[i] < 91)
-
in[i]+=32;
/* lower_case */
+
{
+
if (lower_case)
+
in[i]+=32; /* lower_case */
+
}
else if( in[i] == ':' ) { /* FIXME: Does not support white space before the colon. */ /* in[os..i-1] == the header */ int val_cnt = 0; push_string(make_shared_binary_string((char*)in+os,i-os)); /* Skip the colon and initial white space. */ os = i+1; while((in[os]==' ') || (in[os]=='\t')) os++;
pike.git/src/modules/_Roxen/roxen.c:603:
ADD_FUNCTION("http_decode_string", f_http_decode_string, tFunc(tStr,tStr), 0 ); ADD_FUNCTION("html_encode_string", f_html_encode_string, tFunc(tMix,tStr), 0 ); start_new_program(); ADD_STORAGE( struct header_buf ); set_init_callback( f_hp_init ); set_exit_callback( f_hp_exit );
-
ADD_FUNCTION( "feed", f_hp_feed, tFunc(tStr,tArr(tOr(tStr,tMapping))), 0 );
+
ADD_FUNCTION( "feed", f_hp_feed, tFunc(tStr
tOr(tInt
,
tVoid),
tArr(tOr(tStr,tMapping))), 0 );
ADD_FUNCTION( "create", f_hp_create, tFunc(tOr(tInt,tVoid),tVoid), ID_PROTECTED ); end_class( "HeaderParser", 0 ); } PIKE_MODULE_EXIT { }