How to send large text (String) as response from a REST service to REST client in Java?

yatheendra k v :

I have a restful application, where I need to send text as response to REST client. Now the problem is that sometimes text could be huge nearly 100000 characters.

Can I send large data as normal, plain text?

How to send it through the network to my REST client?

Karol Dowbecki :

You should use HTTP compression by using Accept-Encoding request header and Content-Encoding response header:

GET /your-url HTTP/1.1
Host: www.example.com
Accept-Encoding: gzip, deflate

This will make the compression transparent for most REST API clients. GZIP should be handled out of the box by most client libraries plus it can be disabled by not setting Accept-Encoding header.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=130719&siteId=1