Kong / Kong/insomnia

Redirection not honored properly

Open
#5,335 5 comments 2 reactions 0 assignees View on GitHub
A-networking B-bug D-node-libcurl S-verified
Dominant language
TypeScript
Stars
40k
Forks
2.4k
Avg merge
2d 13h
Merged PRs (30d)
61

Description

### Expected Behavior

Insomnia must switch from POST/PUT to GET method when 303 "See Other" redirection occur (and Following redirection option is enabled).

### Actual Behavior

```curl
* Preparing request to http://127.0.0.1:9000/upload
* Current time is 2022-10-26T20:00:02.449Z
* Enable automatic URL encoding
* Using default HTTP version
* Enable SSL validation
* Enable cookie sending with jar of 2 cookies
* Hostname 127.0.0.1 was found in DNS cache
* Trying 127.0.0.1:9000...
* Connected to 127.0.0.1 (127.0.0.1) port 9000 (#13)

> POST /upload HTTP/1.1
> Host: 127.0.0.1:9000
> User-Agent: insomnia/2022.6.0
> Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> Accept: */*
> Content-Length: 44789

| (43.7 KB hidden)

* We are completely uploaded and fine
* Mark bundle as not supporting multiuse

< HTTP/1.1 303 See Other
< Connection: keep-alive
< Cross-Origin-Resource-Policy: same-origin
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< Location: /upload
< Content-Length: 0
< Date: Wed, 26 Oct 2022 20:00:02 GMT

* Connection #13 to host 127.0.0.1 left intact
* Issue another request to this URL: 'http://127.0.0.1:9000/upload'
* Switch to GET
* Found bundle for host 127.0.0.1: 0x1efd5b2cd10 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#13) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 9000 (#13)

> POST /upload HTTP/1.1
> Host: 127.0.0.1:9000
> User-Agent: insomnia/2022.6.0
> Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> Accept: */*

* Mark bundle as not supporting multiuse

< HTTP/1.1 400 Bad Request
< Connection: keep-alive
< Content-Type: text/html
< Content-Length: 986
< Date: Wed, 26 Oct 2022 20:00:02 GMT

* Received 986 B chunk
* Connection #13 to host 127.0.0.1 left intact
```

### Reproduction Steps

_No response_

### Is there an existing issue for this?

- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.

### Additional Information

According to [HTTP Redirections (developer.mozilla.org)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections#special_redirections), client must switch to GET method when a "See Other" redirection occur.

| Code | Text | Method handling | Typical use case |
| ------------- | ------------- | ---- | ----- |
| 303 | See Other | GET methods unchanged. Others changed to GET (body lost). | Used to redirect after a PUT or a POST, so that refreshing the result page doesn't re-trigger the operation. |

### Insomnia Version

2021.6.0

### What operating system are you using?

Windows

### Operating System Version

Windows 11 x64

### Installation method

Downloaded from official website

### Last Known Working Insomnia version

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the request using a POST or PUT that receives a 303 response with redirection following enabled, then inspect the request-redirection handling. Done means the follow-up request uses GET and omits the original body, matching the expected HTTP 303 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.