Page 1 of 1

Accept gzipped JSON requests

Posted: Mon Nov 21, 2022 5:52 pm
by tadam
In the Xserver2 documentation you mention that "The PTV xServer will accept compressed requests and send compressed responses".
The response compression works succesfully if we set Accept-Encoding header with gzip value.
The problem is the other direction, if we send a gzipped json request to "/services/rs/XRoute/calculateRoute" with Content-Encoding: gzip we get the following error:

Code: Select all

{
    "message": "Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 1, column: 2]",
    "errorLine": 1,
    "errorColumn": 2,
    "faultType": "com.ptvgroup.xserver.exceptions.InvalidRequestFault"
}
Could you help us to solve this issue? May we miss a config somewhere?
It would be a great improvement for us if this worked, becouse we very often send large requests with RequestProfile or binaryFTL.

Thanks,
Adam

Re: Accept gzipped JSON requests

Posted: Mon Nov 21, 2022 7:00 pm
by Bernd Welter
Hello Adam,

honestly spoken I always managed to use some frameworks to create my client classes without the need to dig into the message assemblage by myself. But I would love to assist.

The error message blames a specific character : ascii control character 31 also known as "unit separator". I searched for it and found this wikipedia article.

The character seems to be reserved for some purpose that is an obstacle in your context. How do you assemble the request body? What framework do you use? Can you trace the exact message on the server's logs? Do you use some "database export" structure to create the content?

I also looked for the error message and found another article that mentions that code sequences have to be escaped when being included in a body. Maybe this helps?

Bernd

Re: Accept gzipped JSON requests

Posted: Tue Nov 22, 2022 12:31 pm
by Bernd Welter
Another hint from DEV (thanks, Mathias H.!):
https://www.predic8.com/gzip-compression-filter.htm

Re: Accept gzipped JSON requests

Posted: Tue Nov 22, 2022 5:12 pm
by tadam
This servlet filter works as expected!

Thanks for your help!