Closed plantaest closed 2 months ago
This is because the asPaged method re-uses the same request object changing its URL every time, but keeping everything else. So you only ever get the last one. It should create a all new request with everything copied from the last one. That will take some work
This is complete in 4.3.2
Thanks!
Describe the bug Hello Unirest project maintainers,
Recently, I've been exploring and using the Unirest library for a personal project. I've encountered a rather odd issue and would appreciate your assistance.
With Python's requests library, I can inspect the redirect history when making a call to a link using Response.history. For Unirest, since there isn't a similar feature, I've been using the
asPaged
method to achieve this.To Reproduce Here's the code I'm using:
When running the above code, it prints out as follows:
Expected behavior The "Request URL" value is the same across all 3 responses, which doesn't seem right. According to the javadoc, you note: (HttpResponse::getRequestSummary)
@return a Summary of the HttpRequest that created this response
.Therefore, I expect that the
response.getRequestSummary().getUrl()
method should return the correct URL of the request when used withasPaged
. The expected printout might look like:Screenshots None.
Environmental Data:
Additional context Although it may not be directly related, I believe Unirest should have a feature similar to Response.history in requests, even though asPaged can currently serve as a workaround.
Aside from the issues mentioned above, I find this library to be very good. Thank you!