c/quickwebserver.c
/**
 * Extracting headers from JS object and applying them to the
 * current server response
 * 
 */
Extracting headers from JS object and applying them to the
current server response
Extracting headers from JS object and applying them to the current server response
void acceptHttpHeaders(struct http_response_s *response, JSValue headers, JSContext *ctx) {
	JSPropertyEnum *props;
	uint32_t propsCount, i;
	const char *propValueStr, *propKeyStr;
	JSValue propValue;
	JS_GetOwnPropertyNames(ctx, &props, &propsCount, headers, JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY);
	for(i = 0; i < propsCount; i++) {
        propValue = JS_GetProperty(ctx, headers, props[i].atom);
		if (!JS_IsUndefined(propValue)) {
			propKeyStr = JS_AtomToCString(ctx, props[i].atom);
			propValueStr = JS_ToCString(ctx, propValue);	
			http_response_header(response, propKeyStr, propValueStr);
		}
	}
	JS_FreeValue(ctx, propValue);
}
void acceptHttpHeaders ( struct http_response_s * response , JSValue headers , JSContext * ctx ) { JSPropertyEnum * props ; uint32_t propsCount , i ; const char * propValueStr , * propKeyStr ; JSValue propValue ; JS_GetOwnPropertyNames ( ctx , & props , & propsCount , headers , JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY ) ; for ( i = 0 ; i < propsCount ; i ++ ) { propValue = JS_GetProperty ( ctx , headers , props [ i ] . atom ) ; if ( ! JS_IsUndefined ( propValue ) ) { propKeyStr = JS_AtomToCString ( ctx , props [ i ] . atom ) ; propValueStr = JS_ToCString ( ctx , propValue ) ; http_response_header ( response , propKeyStr , propValueStr ) ; } } JS_FreeValue ( ctx , propValue ) ; }
Extracting headers from JS object and applying them to the
 current server response
Extracting headers from JS object and applying them to the current server response