llhttp
llhttp copied to clipboard
How to interrupt llhttp_execute() in events like 'on_url_complete' ?
I try to interrupt llhttp_execute() by return -1 in events like on_url_complete, on_status_complete, on_header_field_complete, etc. But not work. Would you tell me how to interrupt llhttp_execute() in such events ?
There is an HPE_PAUSED error that you can return from some of the callbacks. on_url_complete is not one of them, but there are others that should help you. Let me know what you think!
For example, if receive an illegal request path like GET /a/b/非法/路径 I want to interrupt parsing an return error immediately.
@ldcsaa perhaps you just want to build llhttp in strict mode? I believe it will do these checks for you. This can be done by compiling it with -DLLHTTP_STRICT_MODE=1.
@indutny
- I had defined LLHTTP_STRICT_MODE 1, but now work.
- Another example - A: on_url_complete receive a legeal request path, but the path does not exists, then I want to interrupt parsing and return error immediately.
- Another example - B: on_header_field_complete / on_header_value_complete parses a field or value that application layer unexpected, then I want to interrupt parsing and return error immediately.
I'll try to implement this. Will send a PR soon.