pike.git / src / modules / _Roxen / roxen.c

version» Context lines:

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, void|int lower_case) + /*! @decl array(string|mapping) feed(string data, void|int(0..1) keep_case)    *! -  +  *! @param data +  *! Fragment of data to parse. +  *! +  *! @param keep_case +  *! By default headers are @[lower_case()]'d in the resulting @tt{Headers@} +  *! mapping. If this parameter is @expr{1@} the header names are kept as is. +  *!    *! @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[-args].u.string; -  int lower_case = 1; +  int keep_case = 0;    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 || args == 2 ) )    Pike_error("Bad number of arguments to feed().\n");    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; +  keep_case = Pike_sp[-args+1].u.integer & 1;    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.git/src/modules/_Roxen/roxen.c:195:       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) +  if(!keep_case && (in[i] > 64 && in[i] < 91))    { -  if (lower_case) -  in[i]+=32; /* 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;
pike.git/src/modules/_Roxen/roxen.c:614:    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 tOr(tInt,tVoid),tArr(tOr(tStr,tMapping))), 0 ); +  ADD_FUNCTION("feed", f_hp_feed, +  tFunc(tStr tOr(tInt01,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   {   }