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












2















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?










share|improve this question

























  • A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

    – T A
    Nov 16 '18 at 12:06






  • 1





    100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

    – MTCoster
    Nov 16 '18 at 12:10











  • @MTCoster thank you soo much. That is a valid point

    – yatheendra k v
    Nov 16 '18 at 12:35











  • Thanks a lot for the information @TA .It helped to proceed.

    – yatheendra k v
    Nov 16 '18 at 12:38











  • For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

    – Roman Vottner
    Nov 16 '18 at 13:08
















2















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?










share|improve this question

























  • A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

    – T A
    Nov 16 '18 at 12:06






  • 1





    100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

    – MTCoster
    Nov 16 '18 at 12:10











  • @MTCoster thank you soo much. That is a valid point

    – yatheendra k v
    Nov 16 '18 at 12:35











  • Thanks a lot for the information @TA .It helped to proceed.

    – yatheendra k v
    Nov 16 '18 at 12:38











  • For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

    – Roman Vottner
    Nov 16 '18 at 13:08














2












2








2








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?










share|improve this question
















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?







java rest






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 12:41









Karol Dowbecki

26.3k93759




26.3k93759










asked Nov 16 '18 at 11:59









yatheendra k vyatheendra k v

234




234













  • A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

    – T A
    Nov 16 '18 at 12:06






  • 1





    100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

    – MTCoster
    Nov 16 '18 at 12:10











  • @MTCoster thank you soo much. That is a valid point

    – yatheendra k v
    Nov 16 '18 at 12:35











  • Thanks a lot for the information @TA .It helped to proceed.

    – yatheendra k v
    Nov 16 '18 at 12:38











  • For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

    – Roman Vottner
    Nov 16 '18 at 13:08



















  • A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

    – T A
    Nov 16 '18 at 12:06






  • 1





    100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

    – MTCoster
    Nov 16 '18 at 12:10











  • @MTCoster thank you soo much. That is a valid point

    – yatheendra k v
    Nov 16 '18 at 12:35











  • Thanks a lot for the information @TA .It helped to proceed.

    – yatheendra k v
    Nov 16 '18 at 12:38











  • For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

    – Roman Vottner
    Nov 16 '18 at 13:08

















A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

– T A
Nov 16 '18 at 12:06





A POST response has generally no size limitations so 100000 characters should not be a problem. There can, however, be a limitation due to the web server and/or implementation you use.

– T A
Nov 16 '18 at 12:06




1




1





100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

– MTCoster
Nov 16 '18 at 12:10





100,000 characters of ASCII text is only 98kB (allow a bit more for unicode) - people transfer much larger chunks of data over the internet all the time (think video)

– MTCoster
Nov 16 '18 at 12:10













@MTCoster thank you soo much. That is a valid point

– yatheendra k v
Nov 16 '18 at 12:35





@MTCoster thank you soo much. That is a valid point

– yatheendra k v
Nov 16 '18 at 12:35













Thanks a lot for the information @TA .It helped to proceed.

– yatheendra k v
Nov 16 '18 at 12:38





Thanks a lot for the information @TA .It helped to proceed.

– yatheendra k v
Nov 16 '18 at 12:38













For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

– Roman Vottner
Nov 16 '18 at 13:08





For HTTP connections I'd recommend chuncked transfer encodings, especially for larger payloads, as this allows you to send data to the client continiously and end the stream with a simple 0

– Roman Vottner
Nov 16 '18 at 13:08












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer



















  • 1





    Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

    – Eric Stein
    Nov 16 '18 at 16:36












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337483%2fhow-to-send-large-text-string-as-response-from-a-rest-service-to-rest-client-i%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














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.






share|improve this answer



















  • 1





    Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

    – Eric Stein
    Nov 16 '18 at 16:36
















2














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.






share|improve this answer



















  • 1





    Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

    – Eric Stein
    Nov 16 '18 at 16:36














2












2








2







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 12:07









Karol DowbeckiKarol Dowbecki

26.3k93759




26.3k93759








  • 1





    Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

    – Eric Stein
    Nov 16 '18 at 16:36














  • 1





    Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

    – Eric Stein
    Nov 16 '18 at 16:36








1




1





Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

– Eric Stein
Nov 16 '18 at 16:36





Note that compression over HTTPS can leave you vulnernable to BREACH attacks.

– Eric Stein
Nov 16 '18 at 16:36




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337483%2fhow-to-send-large-text-string-as-response-from-a-rest-service-to-rest-client-i%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine