Accept gzipped JSON requests

Deals with generic topics such as logging, framework and so on. If you are not sure where to place your topic just put it here.
Post Reply
tadam
Posts: 2
Joined: Thu Jan 13, 2022 12:10 pm

Accept gzipped JSON requests

Post 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
User avatar
Bernd Welter
Site Admin
Posts: 2574
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Accept gzipped JSON requests

Post 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
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 2574
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Accept gzipped JSON requests

Post by Bernd Welter »

Another hint from DEV (thanks, Mathias H.!):
https://www.predic8.com/gzip-compression-filter.htm
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
tadam
Posts: 2
Joined: Thu Jan 13, 2022 12:10 pm

Re: Accept gzipped JSON requests

Post by tadam »

This servlet filter works as expected!

Thanks for your help!
Post Reply