Returning customized error message when LimitRequestLine value exceeds

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Returning customized error message when LimitRequestLine value exceeds

alchemist vk
Hi All,
  If I set LimitRequestLine to 128 and If I give any request field whose length is more than 128, apache returns 400 bad request with default xml error response as below.

< HTTP/1.1 400 Bad Request
< Content-Length: 278
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.</p>
</body></html>
* Closing connection #0
 
Instead of this default xml error response, I am trying to send json formatted customized error response using ErrorDoc directive as below:
ErrorDocument 400 /ErrorDocs/custom_error_400.json

Unfortunately , this custom error message is not getting picked up by apache while sending the error response, instead it sends the default xml error response.

Requesting for help in resolving this .

With regards,
A
 
Reply | Threaded
Open this post in threaded view
|

Re: Returning customized error message when LimitRequestLine value exceeds

alchemist vk
Hi All,
 Any help is appreciated .. 
Please let me know, how to handle above issue.

With Regards,
A

On Fri, Jul 31, 2020 at 7:10 PM alchemist vk <[hidden email]> wrote:
Hi All,
  If I set LimitRequestLine to 128 and If I give any request field whose length is more than 128, apache returns 400 bad request with default xml error response as below.

< HTTP/1.1 400 Bad Request
< Content-Length: 278
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.</p>
</body></html>
* Closing connection #0
 
Instead of this default xml error response, I am trying to send json formatted customized error response using ErrorDoc directive as below:
ErrorDocument 400 /ErrorDocs/custom_error_400.json

Unfortunately , this custom error message is not getting picked up by apache while sending the error response, instead it sends the default xml error response.

Requesting for help in resolving this .

With regards,
A
 
Reply | Threaded
Open this post in threaded view
|

Re: Returning customized error message when LimitRequestLine value exceeds

alchemist vk
Regarding above issue, 
 In apache source code, "rv == APR_ENOSPC" condition in protocol.c gets true and then gets logged with "Request header exceeds LimitRequestFieldSize%s" in error_log.. Since error code  is set  HTTP_BAD_REQUEST, this call returns with 400 error code with XML error response. 
Section "Fcgid and ErrorDocument" in link https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html says, ErrorDocument directive can be used for sending custom error response.. But unfortunately, its not working for me.
Tried also   ProxyErrorOverride On with directive, but of no luck..
 
Help me in this regard.

With regards,
A
  

On Mon, Aug 3, 2020 at 6:25 PM alchemist vk <[hidden email]> wrote:
Hi All,
 Any help is appreciated .. 
Please let me know, how to handle above issue.

With Regards,
A

On Fri, Jul 31, 2020 at 7:10 PM alchemist vk <[hidden email]> wrote:
Hi All,
  If I set LimitRequestLine to 128 and If I give any request field whose length is more than 128, apache returns 400 bad request with default xml error response as below.

< HTTP/1.1 400 Bad Request
< Content-Length: 278
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.</p>
</body></html>
* Closing connection #0
 
Instead of this default xml error response, I am trying to send json formatted customized error response using ErrorDoc directive as below:
ErrorDocument 400 /ErrorDocs/custom_error_400.json

Unfortunately , this custom error message is not getting picked up by apache while sending the error response, instead it sends the default xml error response.

Requesting for help in resolving this .

With regards,
A