pike.git
/
src
/
modules
/
_Roxen
/
roxen.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/_Roxen/roxen.c:10:
#include "machine.h" #include <sys/stat.h> #include <fcntl.h> #include <ctype.h> #include <time.h> #include "fdlib.h" #include "stralloc.h" #include "pike_macros.h"
-
#include "machine.h"
+
#include "object.h" #include "constants.h" #include "interpret.h" #include "svalue.h" #include "mapping.h" #include "array.h" #include "builtin_functions.h" #include "module_support.h" #include "backend.h" #include "threads.h"
pike.git/src/modules/_Roxen/roxen.c:187:
f_aggregate_mapping( 0 ); f_aggregate( 3 ); return; } push_int( 0 ); return; } /*leftovers*/ push_string(make_shared_binary_string((char *)pp, hp->pnt - pp));
-
headers = allocate_mapping( 5 );
+
in = hp->headers; l = pp - hp->headers; /* find first line here */ for( i = 0; i < l; i++ ) if( (in[i] == '\n') || (in[i] == '\r') ) break; push_string(make_shared_binary_string((char *)in, i)); if((in[i] == '\r') && (in[i+1] == '\n')) i++; i++; in += i; l -= i;
-
+
headers = allocate_mapping( 5 );
+
push_mapping(headers);
+
/* Parse headers. */
-
for(i = 0; i < l; i++)
+
for(i = 0; i < l
-2
; i++)
{ if(!keep_case && (in[i] > 64 && in[i] < 91)) { in[i]+=32; /* lower_case */ } else if( in[i] == ':' ) { /* Does not support white space before the colon. This is in line with RFC 7230 product header-field = field-name ":" OWS field-value OWS */
pike.git/src/modules/_Roxen/roxen.c:271:
} } mapping_insert(headers, Pike_sp-2, Pike_sp-1); pop_n_elems(2); } else if( in[i]=='\r' || in[i]=='\n' ) { if( THP->mode & FLAG_THROW_ERROR ) {
-
/*
FIXME:
Reset stack so that backtrace shows faulty header. */
+
/* Reset stack so that backtrace shows faulty header. */
+
pop_n_elems(3);
+
push_string(make_shared_binary_string((const char*)(hp->pnt - str_len),
+
str_len));
Pike_error("Malformed HTTP header.\n"); } else os = i+1; } }
-
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, @ *! void|int no_fold) *! *! @param throw_errors *! If true the parser will throw an error instead of silently *! trying to recover from broken HTTP headers.
pike.git/src/modules/_Roxen/roxen.c:306:
*! @param no_fold *! If true the parser will not parse folded headers. Instead the *! first line of the header will be parsed as normal and any *! subsequent lines ignored (or casue an exception if throw_errors *! is set). */ { INT_TYPE throw_errors = 0; INT_TYPE keep_case = 0; INT_TYPE no_fold = 0;
-
get_all_args(
"create"
,args,".%i%i%i", &throw_errors, &keep_case, &no_fold);
+
get_all_args(
NULL
,args,".%i%i%i", &throw_errors, &keep_case, &no_fold);
+
pop_n_elems(args);
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;
pike.git/src/modules/_Roxen/roxen.c:680:
*! *! Returns @expr{str@} XOR @expr{mask@}. */ static void f_websocket_mask( INT32 args ) { struct pike_string *str, *mask, *ret; const unsigned char *src; unsigned char * restrict dst; size_t len; unsigned INT32 m;
-
get_all_args(
"websocket_mask"
, args, "%n%n", &str, &mask);
+
get_all_args(
NULL
, args, "%n%n", &str, &mask);
if (mask->len != 4) Pike_error("Wrong mask length.\n"); ret = begin_shared_string(str->len); len = str->len; m = get_unaligned32(STR0(mask)); dst = STR0(ret); src = STR0(str);