Recent

Author Topic: TFPHTTPClient get ERROR 414 Request-URI Too Large from server  (Read 918 times)

DidaJI

  • New Member
  • *
  • Posts: 25
TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« on: January 14, 2020, 07:00:46 am »
Hi,
I have a problem with communication with the server via the TFHTTPClient component. PHP scripts are running on the server side. I use the POST method and as long as the request size is less than 8192 bytes, everything is OK. However, if the request grows to a size above 8192 bytes (sending photos in BASE64 format), the server returns an error: 414 Request-URI Too Large. On the server (Apache) I have set the POST query size to 32MB.

Anyone know how to solve it? I need to send a request of about 50KB.

Thank's: Zdenek.

trev

  • Hero Member
  • *****
  • Posts: 822
  • Former Delphi 1-7 and 10.2 User
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #1 on: January 14, 2020, 07:17:06 am »
Perhaps the web browser you're using has a size limit?
o Lazarus v2.1.0 r63598, FPC v3.3.1 r45778, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r361007 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

DidaJI

  • New Member
  • *
  • Posts: 25
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #2 on: January 14, 2020, 07:47:39 am »
If I try to call php script on server from a browser and send it a 50KB request, it normally works. It's not just from the program.

trev

  • Hero Member
  • *****
  • Posts: 822
  • Former Delphi 1-7 and 10.2 User
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #3 on: January 14, 2020, 08:06:39 am »
What does the web server log show?
o Lazarus v2.1.0 r63598, FPC v3.3.1 r45778, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r361007 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

DidaJI

  • New Member
  • *
  • Posts: 25
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #4 on: January 14, 2020, 08:47:19 am »
I use Synology NAS as a server. There is nothing about this query in the Apache error log, and the Acces log does not know where to find the Synology.
I would have to install Apache on another PC and try it out there. Then I get to all the logs.

DidaJI

  • New Member
  • *
  • Posts: 25
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #5 on: January 14, 2020, 10:26:32 am »
The problem seems to be that I am entering data directly into the url and it can only be 8192 characters long.

Simplified:

url := 'http://192.168.64.2/test/' + 'action.php?ID=1' + '&data=' + Base64Str;
HTTPClient := TFPHTTPClient.Create(nil);
html := HTTPClient.Post(url);     

This works if Base64Str is less than 8192 bytes.
In the case of longer data, this will probably have to be entered somehow other than directly into the url.
Would anyone know how?


trev

  • Hero Member
  • *****
  • Posts: 822
  • Former Delphi 1-7 and 10.2 User
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #6 on: January 14, 2020, 12:49:55 pm »
o Lazarus v2.1.0 r63598, FPC v3.3.1 r45778, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (Parallels VM)
o FPC 3.0.4, FreeBSD 12-STABLE r361007 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

DidaJI

  • New Member
  • *
  • Posts: 25
Re: TFPHTTPClient get ERROR 414 Request-URI Too Large from server
« Reply #7 on: January 14, 2020, 02:29:22 pm »
So it works, it was necessary to use FormPost and pass the data as a parameter and not in the URL.

 

TinyPortal © 2005-2018