Lines Matching full:parser
7 #define CALLBACK_MAYBE(PARSER, NAME) \ argument
10 settings = (const llhttp_settings_t*) (PARSER)->settings; \
15 err = settings->NAME((PARSER)); \
18 #define SPAN_CALLBACK_MAYBE(PARSER, NAME, START, LEN) \ argument
21 settings = (const llhttp_settings_t*) (PARSER)->settings; \
26 err = settings->NAME((PARSER), (START), (LEN)); \
29 llhttp_set_error_reason((PARSER), "Span callback error in " #NAME); \
33 void llhttp_init(llhttp_t* parser, llhttp_type_t type, in llhttp_init() argument
35 llhttp__internal_init(parser); in llhttp_init()
37 parser->type = type; in llhttp_init()
38 parser->settings = (void*) settings; in llhttp_init()
87 llhttp_t* parser = malloc(sizeof(llhttp_t)); in llhttp_alloc() local
88 llhttp_init(parser, type, &wasm_settings); in llhttp_alloc()
89 return parser; in llhttp_alloc()
92 void llhttp_free(llhttp_t* parser) { in llhttp_free() argument
93 free(parser); in llhttp_free()
98 /* Some getters required to get stuff from the parser */
100 uint8_t llhttp_get_type(llhttp_t* parser) { in llhttp_get_type() argument
101 return parser->type; in llhttp_get_type()
104 uint8_t llhttp_get_http_major(llhttp_t* parser) { in llhttp_get_http_major() argument
105 return parser->http_major; in llhttp_get_http_major()
108 uint8_t llhttp_get_http_minor(llhttp_t* parser) { in llhttp_get_http_minor() argument
109 return parser->http_minor; in llhttp_get_http_minor()
112 uint8_t llhttp_get_method(llhttp_t* parser) { in llhttp_get_method() argument
113 return parser->method; in llhttp_get_method()
116 int llhttp_get_status_code(llhttp_t* parser) { in llhttp_get_status_code() argument
117 return parser->status_code; in llhttp_get_status_code()
120 uint8_t llhttp_get_upgrade(llhttp_t* parser) { in llhttp_get_upgrade() argument
121 return parser->upgrade; in llhttp_get_upgrade()
125 void llhttp_reset(llhttp_t* parser) { in llhttp_reset() argument
126 llhttp_type_t type = parser->type; in llhttp_reset()
127 const llhttp_settings_t* settings = parser->settings; in llhttp_reset()
128 void* data = parser->data; in llhttp_reset()
129 uint16_t lenient_flags = parser->lenient_flags; in llhttp_reset()
131 llhttp__internal_init(parser); in llhttp_reset()
133 parser->type = type; in llhttp_reset()
134 parser->settings = (void*) settings; in llhttp_reset()
135 parser->data = data; in llhttp_reset()
136 parser->lenient_flags = lenient_flags; in llhttp_reset()
140 llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len) { in llhttp_execute() argument
141 return llhttp__internal_execute(parser, data, data + len); in llhttp_execute()
150 llhttp_errno_t llhttp_finish(llhttp_t* parser) { in llhttp_finish() argument
154 if (parser->error != 0) { in llhttp_finish()
158 switch (parser->finish) { in llhttp_finish()
160 CALLBACK_MAYBE(parser, on_message_complete); in llhttp_finish()
167 parser->reason = "Invalid EOF state"; in llhttp_finish()
175 void llhttp_pause(llhttp_t* parser) { in llhttp_pause() argument
176 if (parser->error != HPE_OK) { in llhttp_pause()
180 parser->error = HPE_PAUSED; in llhttp_pause()
181 parser->reason = "Paused"; in llhttp_pause()
185 void llhttp_resume(llhttp_t* parser) { in llhttp_resume() argument
186 if (parser->error != HPE_PAUSED) { in llhttp_resume()
190 parser->error = 0; in llhttp_resume()
194 void llhttp_resume_after_upgrade(llhttp_t* parser) { in llhttp_resume_after_upgrade() argument
195 if (parser->error != HPE_PAUSED_UPGRADE) { in llhttp_resume_after_upgrade()
199 parser->error = 0; in llhttp_resume_after_upgrade()
203 llhttp_errno_t llhttp_get_errno(const llhttp_t* parser) { in llhttp_get_errno() argument
204 return parser->error; in llhttp_get_errno()
208 const char* llhttp_get_error_reason(const llhttp_t* parser) { in llhttp_get_error_reason() argument
209 return parser->reason; in llhttp_get_error_reason()
213 void llhttp_set_error_reason(llhttp_t* parser, const char* reason) { in llhttp_set_error_reason() argument
214 parser->reason = reason; in llhttp_set_error_reason()
218 const char* llhttp_get_error_pos(const llhttp_t* parser) { in llhttp_get_error_pos() argument
219 return parser->error_pos; in llhttp_get_error_pos()
252 void llhttp_set_lenient_headers(llhttp_t* parser, int enabled) { in llhttp_set_lenient_headers() argument
254 parser->lenient_flags |= LENIENT_HEADERS; in llhttp_set_lenient_headers()
256 parser->lenient_flags &= ~LENIENT_HEADERS; in llhttp_set_lenient_headers()
261 void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled) { in llhttp_set_lenient_chunked_length() argument
263 parser->lenient_flags |= LENIENT_CHUNKED_LENGTH; in llhttp_set_lenient_chunked_length()
265 parser->lenient_flags &= ~LENIENT_CHUNKED_LENGTH; in llhttp_set_lenient_chunked_length()
270 void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled) { in llhttp_set_lenient_keep_alive() argument
272 parser->lenient_flags |= LENIENT_KEEP_ALIVE; in llhttp_set_lenient_keep_alive()
274 parser->lenient_flags &= ~LENIENT_KEEP_ALIVE; in llhttp_set_lenient_keep_alive()
278 void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled) { in llhttp_set_lenient_transfer_encoding() argument
280 parser->lenient_flags |= LENIENT_TRANSFER_ENCODING; in llhttp_set_lenient_transfer_encoding()
282 parser->lenient_flags &= ~LENIENT_TRANSFER_ENCODING; in llhttp_set_lenient_transfer_encoding()
286 void llhttp_set_lenient_version(llhttp_t* parser, int enabled) { in llhttp_set_lenient_version() argument
288 parser->lenient_flags |= LENIENT_VERSION; in llhttp_set_lenient_version()
290 parser->lenient_flags &= ~LENIENT_VERSION; in llhttp_set_lenient_version()
294 void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled) { in llhttp_set_lenient_data_after_close() argument
296 parser->lenient_flags |= LENIENT_DATA_AFTER_CLOSE; in llhttp_set_lenient_data_after_close()
298 parser->lenient_flags &= ~LENIENT_DATA_AFTER_CLOSE; in llhttp_set_lenient_data_after_close()
302 void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled) { in llhttp_set_lenient_optional_lf_after_cr() argument
304 parser->lenient_flags |= LENIENT_OPTIONAL_LF_AFTER_CR; in llhttp_set_lenient_optional_lf_after_cr()
306 parser->lenient_flags &= ~LENIENT_OPTIONAL_LF_AFTER_CR; in llhttp_set_lenient_optional_lf_after_cr()
310 void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled) { in llhttp_set_lenient_optional_crlf_after_chunk() argument
312 parser->lenient_flags |= LENIENT_OPTIONAL_CRLF_AFTER_CHUNK; in llhttp_set_lenient_optional_crlf_after_chunk()
314 parser->lenient_flags &= ~LENIENT_OPTIONAL_CRLF_AFTER_CHUNK; in llhttp_set_lenient_optional_crlf_after_chunk()
318 void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled) { in llhttp_set_lenient_optional_cr_before_lf() argument
320 parser->lenient_flags |= LENIENT_OPTIONAL_CR_BEFORE_LF; in llhttp_set_lenient_optional_cr_before_lf()
322 parser->lenient_flags &= ~LENIENT_OPTIONAL_CR_BEFORE_LF; in llhttp_set_lenient_optional_cr_before_lf()
326 void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled) { in llhttp_set_lenient_spaces_after_chunk_size() argument
328 parser->lenient_flags |= LENIENT_SPACES_AFTER_CHUNK_SIZE; in llhttp_set_lenient_spaces_after_chunk_size()
330 parser->lenient_flags &= ~LENIENT_SPACES_AFTER_CHUNK_SIZE; in llhttp_set_lenient_spaces_after_chunk_size()