Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper handling of HTTP Expect: 100-continue header for POST requests with bodies #1126

Open
dwandro opened this issue Aug 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@dwandro
Copy link

dwandro commented Aug 30, 2023

Describe the bug

When Mockoon proxy server receives an HTTP POST request with Expect: 100-continue header and a body from the client, it does not respond with an HTTP 100 response. This prevents the client from sending the actual POST request with body, and causes the proxy call to fail with a timeout.

To Reproduce

To reproduce the current behavior
  1. Setup an environment with no routes and proxy to any address (http://www.google.com will suffice).
  2. Listen on any port (we will use port 3000 for the example).
  3. Send an HTTP POST call to Mockoon with an Expect: 100-continue header: curl -v http://127.0.0.1:3000/ -H 'Expect: 100-continue' -X POST -d '{"foo": "bar"}'
  4. The request will hang.
To work around the problem and produce the desired behavior
  1. Change the port that Mockoon is running on to something different (we will use port 3001 for the example).
  2. Setup NGINX to listen on the port that Mockoon was originally running on and proxy traffic to the port from step 1, removing the Expect header before sending the request to Mockoon:
    server {
      listen 3000 default_server;
      location / {
        proxy_set_header Expect "";
        proxy_pass http://localhost:3001;
     }
    }
    
  3. Send an HTTP POST call to NGINX with an Expect: 100-continue header: curl -v http://127.0.0.1:3000/ -H 'Expect: 100-continue' -X POST -d '{"foo": "bar"}'
  4. NGINX will respond with an HTTP 100 response, and the client will send the POST request (which will result in an error, because the upstream doesn't allow POST requests).
  5. The request does not hang.

Mockoon version:

6.1.0, 4.1.0

OS / OS version:

macOS 13.x, Windows 10, Ubuntu 22.04

@255kb 255kb added the bug Something isn't working label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants