How to change the maximum URL length supported in the web request sent by HTTPClient/RESTClient

Symptom

If the URL in the web request sent by HTTPClient/RESTClient exceeds 8 KB, the execution fails.

Environment

PowerBuilder 2021 Build 1506 and later

Cause

Though PowerBuilder supports 64 KB URL in a web request, Web Server has its own limit on the URL length.

Solution

You can refer to the following solutions to change the length limit for different types of Web Servers.

  • IIS Server

    Modify the following information in the web.config file (locates in the service directory by default). The limit on URI is 2 KB by default.

    Add the following settings under the system.webServer/security/ section in the web.config file:

    <system.webServer> 
       <security> 
           <requestFiltering> 
               <requestLimits maxAllowedContentLength="930000000"  maxUrl="4096000" maxQueryString="2048000" /> 
           </requestFiltering> 
       <security> 
    <system.webServer>

    Add the following settings under the system.web/httpRuntime section:

    <configuration>
        <system.web>
            <httpRuntime maxRequestLength="4096000" maxQueryStringLength="2048000" /> 
        </system.web>
    </configuration>
  • Kestrel Server

    Add the following code in configwebhost. The limit on URI is 8 KB by default.

    webBuilder.ConfigureKestrel(m => m.Limits.MaxRequestLineSize = 80000);
  • Apache Server

    Modify the httpd.conf file (locates in % Apache Server %\conf\httpd.conf by default) corresponding to the service. Add the following settings (this file doesn’t have these configurations but the limit on URI is 8190 by default):

    LimitRequestLine 80000
    LimitRequestFieldSize 80000
  • Nginx Server

    Modify the nginx.conf file (locates in %Nginx Server%\conf\ by default) corresponding to the service. Add the following setting (this file doesn’t have this configuration but the limit on URI is 8 KB by default):

    large_client_header_buffers 16 64k