AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
237 stars 20 forks source link

Redirect info incorrect #137

Closed gerukin closed 2 years ago

gerukin commented 2 years ago

Given this:

### Redirect
https://httpbin.org/redirect-to?url=https://httpbin.org/status/204

I get this in the output:

---------------------

=== Redirect ===

GET https://httpbin.org/status/204
accept-encoding: gzip, deflate, br
accept: */*
user-agent: httpyac

HTTP/1.1 302  - FOUND
access-control-allow-credentials: true
access-control-allow-origin: *
connection: close
content-length: 0
content-type: text/html; charset=utf-8
date: Tue, 28 Jun 2022 04:39:27 GMT
location: https://httpbin.org/status/204
server: gunicorn/19.9.0

---------------------

=== Redirect ===

GET https://httpbin.org/status/204
accept-encoding: gzip, deflate, br
accept: */*
user-agent: httpyac

HTTP/1.1 204  - NO CONTENT
access-control-allow-credentials: true
access-control-allow-origin: *
connection: close
content-type: text/html; charset=utf-8
date: Tue, 28 Jun 2022 04:39:28 GMT
server: gunicorn/19.9.0

You can see that the GET https://httpbin.org/status/204 is shown twice, including for the initial request. The initial request is never shown.

While I suspect this is something which comes from the underlying http library... including here just in case.

In this case it's obvious something's missing... but just for some background... I got tripped by this while looking into an http to https redirect. Since it kept showing https the whole time, I couldn't understand why I was being redirected to the same URL one more time.

AnWeber commented 2 years ago

Thanks for the tip. I had overlooked that. Got before the hook call already updates the request options for the next call. For this reason I now remember the original request options myself and output them.