marcocir 2 Posted April 26, 2023 Hi All. I have a Delphi 10.4 web broker application that raises this exception receiving a request with a json text > 16K bytes (default max line length). I failed to find a simple way to set idIOHanlder MaxLineLength property to a higher value, so I wonder if someone can help me to find a solution that let my web broker API server accept calls with a larger json text attached, thanks a lot. Marco Share this post Link to post
Remy Lebeau 1436 Posted April 26, 2023 How is your client sending the JSON request, exactly? What does the raw request look like? Indy's TIdHTTPServer (which TIdHTTPWebBrokerBridge uses internally) does not read body content line-by-line, only the request line and headers are read as lines, so you should not be getting a MaxLineLength error under normal conditions if the JSON is in the request body. Is the client sending the JSON in the URL query parameters instead, perhaps? Share this post Link to post
AWeber 0 Posted April 26, 2023 Hi, recently I got the same error with TidHttp because the server responded with a Transfer Encoding chunked header, but the response did not contain the hex encoded chunk len lines. So the read routine tried to read the first very long text line as chunk len and this leads to the exception. May be the server has the same problem if the client posts data with the header set chunked, but the post stream is not chunked. Share this post Link to post
Alexander Sviridenkov 360 Posted April 26, 2023 You can create explicit IOHandler, set it as IOHandler for client component and set MaxLineLength property for IOHandler instance. Share this post Link to post
Remy Lebeau 1436 Posted April 26, 2023 4 hours ago, AWeber said: May be the server has the same problem if the client posts data with the header set chunked, but the post stream is not chunked. I suppose that is a possibility, but it is less common for a client to send a chunked request since that requires the client to have foreknowledge that the server actually supports HTTP 1.1 and chunked transfers before making the request. Share this post Link to post
Remy Lebeau 1436 Posted April 26, 2023 4 hours ago, Alexander Sviridenkov said: You can create explicit IOHandler, set it as IOHandler for client component and set MaxLineLength property for IOHandler instance. That would work for TIdHTTP, but for TIdHTTPServer you would need access to its OnConnect event in order to update each connected client's IOHandler.MaxLineLength, and AFAIK WebBroker does not expose access to that event. But, I don't have any experience with WebBroker, so who knows... Share this post Link to post
marcocir 2 Posted April 27, 2023 17 hours ago, Remy Lebeau said: How is your client sending the JSON request, exactly? What does the raw request look like? Indy's TIdHTTPServer (which TIdHTTPWebBrokerBridge uses internally) does not read body content line-by-line, only the request line and headers are read as lines, so you should not be getting a MaxLineLength error under normal conditions if the JSON is in the request body. Is the client sending the JSON in the URL query parameters instead, perhaps? Exactly, and thanks, perhaps.. I was trying to use query parameters to send the JSON payload. ;( Once, not without some initial trouble, I switched to a post call, sending JSON in the body, the error disappeared. Thank you all. Marco Share this post Link to post
marcocir 2 Posted April 27, 2023 16 hours ago, Alexander Sviridenkov said: You can create explicit IOHandler, set it as IOHandler for client component and set MaxLineLength property for IOHandler instance. Hi Alexander. I tried to do the same before asking here, without being able to identify exactly which is the "client component" where to set my IoHandler, thanks! Marco Share this post Link to post
Remy Lebeau 1436 Posted April 27, 2023 (edited) 5 hours ago, marcocir said: Exactly, and thanks, perhaps.. I was trying to use query parameters to send the JSON payload. ;( Not a good idea to send JSON in the query parameters. But, I suppose it is not forbidden either, so I should probably update TIdHTTPServer to handle that more cleanly, like sending a "414 URI Too Long " response instead of raising an exception. TIdHTTPServer already has a MaximumHeaderLineCount property (which raises an exception instead of sending a "431 Request Header Fields Too Large" response). I could add new MaximumUriLength and MaximumHeaderLineLength properties. I've opened a new ticket for these features: #474: Update TIdHTTPServer to handle long URIs and long request headers more cleanly Quote Once, not without some initial trouble, I switched to a post call, sending JSON in the body, the error disappeared. OK Edited April 27, 2023 by Remy Lebeau Share this post Link to post
marcocir 2 Posted April 27, 2023 1 hour ago, Remy Lebeau said: Not a good idea to send JSON in the query parameters. But, I suppose it is not forbidden either, so I should probably update TIdHTTPServer to handle that more cleanly, like sending a "414 URI Too Long " response instead of raising an exception. TIdHTTPServer already has a MaximumHeaderLineCount property (which raises an exception instead of sending a "431 Request Header Fields Too Large" response). I could add new MaximumUriLength and MaximumHeaderLineLength properties. Share this post Link to post