brianleroux / tiny-json-http

:anchor: Minimalist HTTP client for JSON payloads.
172 stars 18 forks source link

Allow 301 and 302 redirects. #39

Closed clintjhill closed 1 year ago

clintjhill commented 1 year ago

The current implementation errors when 301 or 302 statusCodes are returned. A potential fix for #20 I believe. This implementation does not "follow" redirects, rather it simply does not throw exceptions allowing the client to handle the redirect.

👀 - there was a weird broken test for OPTIONS, looks like a fat-finger, and even after fixing that the tests were failing due to a 405 statusCode that https://mozilla.org/en-US/ was returning.

ryanblock commented 1 year ago

This is good! Maybe we should also just follow redirects, or have an option to do that?

clintjhill commented 1 year ago

I'm all for a "follow" option. Seems reasonable. 🤝

Personally, when using a HTTP client like this I don't want to actually follow requests. Most often I'm only interested in the atomic request/response to assert my flows. But I see the fit & purpose of a "follow" option if using this client for integration style testing.

It would be my opinion to ship this change, let it simmer, and see if smarter folks than me come up with a nice follow feature.