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

version» Context lines:

pike.git/src/modules/_Roxen/roxen.c:34:   /*! @module _Roxen    */      /*! @class HeaderParser    *!    *! Class for parsing HTTP-requests.    */      #define FLAG_THROW_ERROR 1   #define FLAG_KEEP_CASE 2 + #define FLAG_NO_FOLD 4      #define THP ((struct header_buf *)Pike_fp->current_storage)   struct header_buf   {    unsigned char *headers;    unsigned char *pnt;    ptrdiff_t hsize, left;    int slash_n, tslash_n, spc;    int mode;   };
pike.git/src/modules/_Roxen/roxen.c:88:    *! @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;    struct header_buf *hp = THP;    int keep_case = hp->mode & FLAG_KEEP_CASE; +  int fold = !(hp->mode & FLAG_NO_FOLD);    int str_len;    int tot_slash_n=hp->tslash_n, slash_n = hp->slash_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");
pike.git/src/modules/_Roxen/roxen.c:235:    break;       /* FIXME: Remove header value trailing spaces. */    push_string(make_shared_binary_string((char*)in+os,j-os));    val_cnt++;       if((in[j] == '\r') && (in[j+1] == '\n')) j++;    os = j+1;    i = j;    /* Check for continuation line. */ -  } while ((os < l) && ((in[os] == ' ') || (in[os] == '\t'))); +  } while ((os < l) && fold && ((in[os] == ' ') || (in[os] == '\t')));       if (val_cnt > 1) {    /* Join partial header values. */    f_add(val_cnt);    }       if((tmp = low_mapping_lookup(headers, Pike_sp-2)))    {    if( TYPEOF(*tmp) == PIKE_T_ARRAY )    {
pike.git/src/modules/_Roxen/roxen.c:283:    push_mapping( headers );    f_aggregate( 3 ); /* data, firstline, headers */   }      static void f_hp_create( INT32 args )   /*! @decl void create(void|int throw_errors, void|int keep_case)    */   {    INT_TYPE throw_errors = 0;    INT_TYPE keep_case = 0; -  get_all_args("create",args,".%i%i", &throw_errors, &keep_case); +  INT_TYPE no_fold = 0; +  get_all_args("create",args,".%i%i%i", &throw_errors, &keep_case, &no_fold);       if (THP->headers) {    free(THP->headers);    THP->headers = NULL;    }       THP->mode = 0;    if(throw_errors) THP->mode |= FLAG_THROW_ERROR;    if(keep_case) THP->mode |= FLAG_KEEP_CASE; -  +  if(no_fold) THP->mode |= FLAG_NO_FOLD;       THP->headers = xalloc( 8192 );    THP->pnt = THP->headers;    THP->hsize = 8192;    THP->left = 8192;    THP->spc = THP->slash_n = 0;   }      /*! @endclass    */
pike.git/src/modules/_Roxen/roxen.c:666:       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(tInt01,tVoid),tArr(tOr(tStr,tMapping))), 0); -  ADD_FUNCTION( "create", f_hp_create, tFunc(tOr(tInt,tVoid) tOr(tInt,tVoid),tVoid), ID_PROTECTED ); +  ADD_FUNCTION( "create", f_hp_create, tFunc(tOr(tInt,tVoid) tOr(tInt,tVoid) tOr(tInt,tVoid),tVoid), ID_PROTECTED );    end_class( "HeaderParser", 0 );   }      PIKE_MODULE_EXIT   {   }