Proxyman icon indicating copy to clipboard operation
Proxyman copied to clipboard

Scripting Tool turning 304 responses into 200 with non-empty body

Open reekystive opened this issue 1 year ago • 3 comments

Description

When using the Scripting Tool to forward requests to a local server, the request with status code 304 before forwarding will become 200, with a strange non-empty body, causing the browser failed to execute javascript code.

Steps to Reproduce

  1. Start a local http dev server.
  2. Enable system proxy in Proxyman (or using SwitchyOmega in a browser).
  3. Use Scripting Tool to redirect http requests (from https://example.com to http://localhost:8080).
  4. If local dev server returns 304 Not Modified, the browser may receives 200 OK with a strange body:
0

HTTP/1.1 304 Not Modified
Access-Control-Allow-Origin: *
Content-Type: application/javascript; charset=utf-8
Accept-Ranges: bytes
ETag: W/"182a1-eQ3lKViLjXY/D1cwx5lSaWKT2Io"
Content-Encoding: gzip
Date: Thu, 14 Dec 2023 07:05:26 GMT
Connection: keep-alive
Keep-Alive: timeout=5
transfer-encoding: chunked

0

Current Behavior

Response header received in Chrome (should be 304 Not Modified):

Screen Capture 2023-12-14 at 15 13 42

Response body received in Chrome (should be empty):

Screen Capture 2023-12-14 at 15 14 52

Corresponding request in Proxyman:

Screen Capture 2023-12-14 at 15 15 28

Script using in Proxyman:

Screen Capture 2023-12-14 at 15 16 17

Expected Behavior

Chrome received 304 Not Modified with an empty body, just as before it was forwarded.

Environment

  • App version: Proxyman 4.14.0 (49500)
  • macOS version: macOS Sonoma

reekystive avatar Dec 14 '23 07:12 reekystive

Look like Chrome returns 304 because the cache is hit.

Can you add these response Header (from the No Caching Tool): https://docs.proxyman.io/advanced-features/no-caching#3.-how-it-works ?

It forces the Google Chrome to get the real data instead of using the cache.

NghiaTranUIT avatar Dec 14 '23 07:12 NghiaTranUIT

There's no issue if I enable "No Caching" in Proxyman or enable "Disable cache" in Chrome DevTools. But my questions is where does this strange body came from?

0

HTTP/1.1 304 Not Modified
Access-Control-Allow-Origin: *
Content-Type: application/javascript; charset=utf-8
Accept-Ranges: bytes
ETag: W/"182a1-eQ3lKViLjXY/D1cwx5lSaWKT2Io"
Content-Encoding: gzip
Date: Thu, 14 Dec 2023 07:05:26 GMT
Connection: keep-alive
Keep-Alive: timeout=5
transfer-encoding: chunked

0

reekystive avatar Dec 14 '23 07:12 reekystive

Look like it's not from Proxyman. It's from the Google Chrome.

NghiaTranUIT avatar Dec 14 '23 14:12 NghiaTranUIT