question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Omitting a forward slash from http domain produces Bad HTTP request line

See original GitHub issue

Problem Description

Running a GET request for “http://wikipedia.com” will produce the following output: 35.176.198.120:43784: clientconnect << Bad HTTP request line: b'GET http://wikipedia.com HTTP/1.1' ::ffff:35.176.198.120:43784: request -> HTTP protocol error in client request: Bad HTTP request line: b'GET http://wikipedia.com HTTP/1.1' 35.176.198.120:43784: clientdisconnect

The request status, headers and body are as follows for the client: 400 <CIMultiDictProxy('Server': 'mitmproxy 5.3.0', 'Connection': 'close', 'Content-Length': '306', 'Content-Type': 'text/html')> b'<html>\n <head>\n <title>400 Bad Request</title>\n </head>\n <body>\n <h1>400 Bad Request</h1>\n <p>HttpSyntaxException(&quot;Bad HTTP request line: b&#x27;GET http://wikipedia.com HTTP/1.1&#x27;&quot;)</p>\n </body>\n </html>

Running a GET request for “http://wikipedia.com/” will not produce this error. Nor will “https://wikipedia.com”. Curl runs the problematic URL fine as it appends the missing trailing slash before running the request which can be seen by printing flow.request.url.

Steps to reproduce the behavior:

  1. Start mitmproxy using “mitmdump -s proxy_server.py --set block_global=false”
  2. Run a GET request with mitm proxy as the request proxy for “http://wikipedia.com”.

System Information

Mitmproxy: 5.3.0 Python: 3.7.9 OpenSSL: OpenSSL 1.1.1h 22 Sep 2020 Platform: Linux-4.14.203-156.332.amzn2.x86_64-x86_64-with-glibc2.2.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dlbascommented, Feb 13, 2021

This generally sounds good to me. Have you checked if there is more current guidance in any of the 72xx HTTP RFCs?

This document (RFC 7230) says that providing “/” as a path in case of empty URI’s path component is a MUST.

0reactions
mhilscommented, Mar 5, 2021

@pdelagrave: you’re encouraged to switch to master (we do have binaries for dev snapshots as well) and report more bugs there 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Error 400 Bad Request: What It Is and How to Fix It
If the address is missing a forward slash after the domain, this may be the cause of the “HTTP 400 Bad Request” Error....
Read more >
When should I use a trailing slash in my URL? - Stack Overflow
Omitting the slash even if you indeed mean the slashed version gives you an additional HTTP request penalty. Which is always bad (think...
Read more >
To slash or not to slash | Google Search Central Blog
This behavior is beneficial because it reduces duplicate content. In the particular case of redirects to trailing slash URLs, our search results will...
Read more >
What causes double slashes in url path?
The problem is compounded by relative links once a crawler finds a URL with a duplicate slash. If http://www.example.com/path//filename.html ...
Read more >
Should You Use a Trailing Slash in Your Website's URLs?
URLs serve as the architecture for your website Each page will have a unique URL signifying its location on the internet Regardless of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found