Klaus Demo bjoern / 45a5922
Fixes Jonas Haag 2 years ago
1 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2525 return request;
2626 }
2727
28 /* should not be called without `Request_clean` when `request->parser.field` can contain an object */
28 /* Initialize Requests, or re-initialize for reuse on connection keep alive.
29 Should not be called without `Request_clean` when `request->parser.field`
30 can contain an object */
2931 void Request_reset(Request* request)
3032 {
3133 memset(&request->state, 0, sizeof(Request) - (size_t)&((Request*)NULL)->state);
4244 free(request);
4345 }
4446
45 /* Request_reset should be called after this, to reset request->parser.field to NULL */
47 /* Close and DECREF all the Python objects in Request.
48 Request_reset should be called after this if connection keep alive */
4649 void Request_clean(Request* request)
4750 {
4851 if(request->iterable) {
105108 static int
106109 on_message_begin(http_parser* parser)
107110 {
111 assert(PARSER->field == NULL);
108112 REQUEST->headers = PyDict_New();
109113 return 0;
110114 }
130134 {
131135 if(PARSER->last_call_was_header_value) {
132136 /* We are starting a new header */
133 Py_Clear(PARSER->field);
137 Py_XDECREF(PARSER->field);
134138 PARSER->field = _Unicode_FromStringAndSize("HTTP_", 5);
135139 PARSER->last_call_was_header_value = false;
136140 PARSER->invalid_header = false;