Eduard Lebedyuk · May 9, 2018

Redirect longer than 3972 characters is truncated

I need to redirect user to a url, which is 5000+ characters long.
To do that I set:

set %response.Redirect = url

However, in the browser I receive this header:

LOCATION: <First 3972 characters of the 'url' variable>

In WriteHTTPHeader method of %CSP.Response, where the LOCATION header is

Write "Location: ", <Redirect>,!

After I added a buffer flush, after the above-mentioned line:

Write *-3

Then in browser I received full, correct value of a LOCATION header.
Is there a better solution?
It's a rest API, so maybe there's some callback method I can override to flush the output buffer? Set device mode? Change buffer size?

0 313
Discussion (8)1
Log in or sign up to continue

How about using ServerSideRedirect ?

ServerSideRedirect  doesn't work in that context (OAuth authentication) unfortunately.

I also tried setting LOCATION header directly (via SetHeader method) - in that case I get the same truncated output.


I googled around "max url lenght"  and found
#1 browser depending
#2 limit yourself to 2048 char.
So is your redirect just URL or  URL?urlparams=...... 

#2 limit yourself to 2048 char.

Nowadays it's fine. Most browsers work with long URLs.

So is your redirect just URL or  URL?urplarams=...... 

It's  URL?urplarams=...... 

One parameter is 5000+ symbols long.

is it persistent across different browsers ?

IF YES -> our problem,
OR do you see different cut off lengths.
 I especially distrust IE !

It's on Cache side as adding

Write *-3

fixes the problem.


docs say:

 Sends any buffered output out the TCP connection; that is, executes a TCP SEND operation on the data in the output buffer.
If the data is compressed (/GZIP) stream data, *-3 sends the data without marking the compression endpoint.

I interpret this: 
up to some limit, it is sent somehow automatically
and the eventual rest needs to be pushed out manually or gets never sent or is to late.

???  surprise

The problem with write *-3 is that it is currently added to a system code. I'm searching for a better solution.