notroj / neon

neon - an HTTP/1.1 and WebDAV client library with a C API
https://notroj.github.io/neon/
131 stars 33 forks source link

Move Location: handling into ne_request, mostly obsoleting the ne_redirect API #152

Closed notroj closed 6 months ago

notroj commented 6 months ago
Add ne_get_response_location(). Set descriptive errors for 3xx responses with a Location header.

* src/ne_request.c (ne_get_response_location): New function.
  (ne_end_request): Set descriptive error for a redirect.

* src/ne_redirect.c (create, post_send, free_redirect, ne_redirect_register): Rewritten as a simple cache of the URI returned by ne_get_response_location. Handle any 3xx response.

* src/ne_redirect.h: Note API is deprecated.

* src/ne_request.h: Describe ne_get_response_location.

* test/request.c (redirect_error): New test.

* test/redirect.c (serve_redir): Removed. (check_redir, redirects): Simplify, and enhance to test ne_get_response_location() directly. Add more relative URI checks and fragment handling.