#1 2016-02-02 18:12:18

mmbk
Member
Registered: 2015-07-06
Posts: 9

THttpApiServer Error "HTTP Error 400. The request URL is invalid."

Hi,

I have a Http Server (THttpApiServer) that works great. For compatibility reasons I had to make it accept REST calls. These calls have large parameters, but every time a parameter exceeds 260 strings gives this error. How can I increase this limit?

Call example:

http://localhost:8080/datasnap/rest/metodos/cadastraTemplateDigital/MCAxMDAgICAgICAgICAgICAgICAgIDY2OSCdAgMDAFgSGTB3d3d3d3d3d3d3d3d3d3d3d3d3dwkIBQQCOzk3NTQyMC4uLXd3DAsJBwUCOzk2NDMyMC4tLXd3Dw0LCAUCADg2N1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa333333333333333333333333333333333333333333332222222222222222222222222222222222222222222224aaaaaaaaaaaaaaaa

Thank you

Offline

#2 2016-02-03 07:25:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

I do not understand the URI. There is no parameter, just a huge base 64 content.
This is far from a REST design. Perhaps DataSnap design - but pretty weird for a REST identifier.
Where does it break?
There is a limitation of parameter name maximum size at URI level, depending on the client browser used.
Large parameters should be supplied as POST body, not at URI level.

Offline

#3 2016-02-03 10:53:42

mmbk
Member
Registered: 2015-07-06
Posts: 9

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

Hi ab,

Thank you for reply!

It's should be datasnap design. The problem is the number of char after the last '/', is what I called 'parameter' ('MCAxMDAgICAg ... aaaaa').
If it have less than 260 char everything works fine. If I send more than 260 char the function

Err: = Http.ReceiveHttpRequest (fReqQueue, ReqID, 0, Req ^, Length (ReqBuf), bytesRead);

inside

procedure THttpApiServer.Execute;

is not returned and the error ('HTTP Error 400. The request URL is invalid.') is generated.

Any idea how to solve this?

thank you

Last edited by mmbk (2016-02-03 13:14:27)

Offline

#4 2016-02-03 11:25:46

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

Normally about 2000 chars in a URL is fine. Not sure why you have the 260 char limit.

Only solution I can think of is to find a way to shorten the URL

Offline

#5 2016-02-03 12:08:19

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,539
Website

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

@mmbk
Check HTTP.SYS error log files (usually in this folder) C:\Windows\System32\LogFiles\HTTPERR\ 
Is some URL -related errors there? It is may me a windows (http.sys) level security to prevent a "long-url" type of attack

Last edited by mpv (2016-02-03 12:08:32)

Offline

#6 2016-02-03 12:42:07

mmbk
Member
Registered: 2015-07-06
Posts: 9

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

esmondb wrote:

Normally about 2000 chars in a URL is fine. Not sure why you have the 260 char limit.
Only solution I can think of is to find a way to shorten the URL

esmondb It is not a limitation of the size of the URL , but the text between '/'.


mpv wrote:

Check HTTP.SYS error log files (usually in this folder)

mpv I check it and find this:

"2016-02-03 12:15:50 ::1%0 57776 ::1%0 888 HTTP/1.1 GET /root/NoteFile/MCAxMDAgICAgICAgICAgICAgICAgIDY2OSCdAgMDAFgSGTB3d3d3d3d3d3d3d3d3d3d3d3d3dwkIBQQCOzk3NTQyMC4uLXd3DAsJBwUCOzk2NDMyMC4tLXd3Dw0LCAUCADg2N1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa333333333333333333333333333333333333333333332222222222222222222222222222222222222222222224aaaaaaaaaaa/blob 400 - URL -"

It was a test I did in the Samples 26 " mORMot\SQLite3\Samples\26 - RESTful ORM \ RESTserver.dproj ". I tried to make a GET with an ID with more than 260 char and I had the same problem. But if I use a DataSnap server or a Ninja IO server, the GET command works.

Printscreen from IO Ninja accept this command
IO Ninja printscreen


Any idea how to solve this?

Last edited by mmbk (2016-02-03 12:51:13)

Offline

#7 2016-02-03 14:29:22

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,539
Website

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

Your URl is invalid from HTTP.SYS point of view. And http.sys driver drop such packages. See this article about HTTP.SYS error codes (your code is "URL"  mean "A parse error occurred while processing a URL").
DataSnap server do not use HTTP.SYS, so it work.
You can either switch mORMot to socket server type, or edit a registry values to increase allowed URL size as described in this article

Last edited by mpv (2016-02-03 14:30:25)

Offline

#8 2016-02-03 15:26:57

mmbk
Member
Registered: 2015-07-06
Posts: 9

Re: THttpApiServer Error "HTTP Error 400. The request URL is invalid."

Thank you all for your time.

mpv thanks for the help, I chose to change the Windows Registry (even knowing the risks involved) and it worked! Thank you!

ps.: I changed my server to THttpServer (changing two command lines) as mpv mentioned and it worked too!

I love this framework!

Thank you again!

Last edited by mmbk (2016-02-03 15:47:33)

Offline

Board footer

Powered by FluxBB