Why is the request with malformed URL not reaching my API Proxy ?

When I make an API call with a malformed URL (as shown below) I notice that the request does not reach my API Proxy

curl -v "http://<hostalias>/v1/basepath/some%%"

Instead I am getting 400 Bad Request with the below HTML page

HTTP/1.1 400 Bad Request
...
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>An error occurred.</h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
</body>
</html>
Can you please explain from where am I getting this error and why is the request not reaching my API Proxy ?
Solved Solved
0 1 2,242
1 ACCEPTED SOLUTION

  1. I found that the 400 Bad Request with HTML page is being returned by the Nginx server. Hence it does not even get logged in the Nginx Access logs or reach the API Proxy.
  2. This is because using just the "%" symbol in URI is bad syntax and treated as an error by the Nginx server.
  3. As per RFC 3986, a percent symbol should be followed by two meaningful hexadecimal digits. For ex: To represent space in URI, you can use "%20" (URL encoding for space)
  4. As per wikipedia it says "The characters allowed in a URI are either reserved or unreserved (or a percent character as part of a percent-encoding)."

View solution in original post

1 REPLY 1

  1. I found that the 400 Bad Request with HTML page is being returned by the Nginx server. Hence it does not even get logged in the Nginx Access logs or reach the API Proxy.
  2. This is because using just the "%" symbol in URI is bad syntax and treated as an error by the Nginx server.
  3. As per RFC 3986, a percent symbol should be followed by two meaningful hexadecimal digits. For ex: To represent space in URI, you can use "%20" (URL encoding for space)
  4. As per wikipedia it says "The characters allowed in a URI are either reserved or unreserved (or a percent character as part of a percent-encoding)."