Issuing an HTTP request from a stream module
Eran Kornblau
eran.kornblau at kaltura.com
Sun Apr 14 13:24:35 UTC 2019
Thank you, Roman, this is very helpful!
> In nginx source there are at least 2 examples of how to write an HTTP client:
>
> - OCSP stapling (src/event/ngx_event_openssl_stapling.c)
> - mail_auth module (src/mail/ngx_mail_auth_http_module.c)
>
> Also, the HTTP proxy module does this as well, but the entire module is much more complicated.
>
I was familiar with the proxy module, but since it depends on 'upstream' it is harder to derive the required code from it,
wasn't familiar with the 2 other implementations you mentioned...
I looked at ngx_event_openssl_stapling, something small that I noticed - I didn't see any handling
for the case in which the response headers are larger than the allocated buffer (16K).
While it is an edge case, unless I'm missing something, the code will call recv with decreasing sizes,
until the buffer will eventually get full, and recv will be called with size=0.
I think it makes sense to check the size and print some error if this happens.
> --
> Roman Arutyunyan
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.nginx.org%2Fmailman%2Flistinfo%2Fnginx-devel&data=02%7C01%7Ceran.kornblau%40kaltura.com%7Cb0737c825fe744818b6608d6bc2db562%7C0c503748de3f4e2597e26819d53a42b6%7C0%7C0%7C636903301834679796&sdata=Qf53use9qeujNa2g4MKBy2DBtgLCeEi7D3j3M%2BftGXg%3D&reserved=0
>
Thanks,
Eran
More information about the nginx-devel
mailing list