Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:38:52+00:00 2026-06-10T00:38:52+00:00

I am using HttpClient to send a request a server which is supposed to

  • 0

I am using HttpClient to send a request a server which is supposed to return xml data. This data is returned as chunked data. I am then trying to write the received xml data to a file. The code I use is shown below:

    HttpEntity entity = response.getEntity();
    InputStream instream = entity.getContent();

        try {
            // do something useful
            InputStreamReader isr = new InputStreamReader(instream);
            FileWriter pw;

            pw = new FileWriter(filename, append);

            OutputStreamWriter outWriter = new OutputStreamWriter(new FileOutputStream(filename, append), "UTF-8");
            BufferedReader rd = new BufferedReader(isr);

            String line = "";
            while ((line = rd.readLine()) != null) {
                // pw.write(line);
                outWriter.write(line);
            }
            isr.close();
            pw.close();
        } finally {
            instream.close();
        }

This results in data that looks as follows to be printed to the file:
resulting file

This code works for non chunked data. How do I properly handle chunked data responses using HttpClient. Any help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:38:53+00:00Added an answer on June 10, 2026 at 12:38 am

    I don’t think that your problem is the chunking of data.

    XML data is plain text data – chunking it means that it is split into several parts that are transfered after another. Therefore each chunk should contain visible plain text xml data which is obviously not the case as shown in the data picture.

    May be the content is encoded compressed via gzip or it is not plain text XML but binary encoded XML (e.g. like WBXML).

    What concrete type you have you can see from the sent server response headers, especially the used mime type it contains.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to send post/get request using any HTTPClient which are explained here
i want to send request from android to java tomcat server using servlet, then
I'm trying to send a GET request using HttpClient , but I keep getting
I'm using HttpClient to post then retrieve something in Android, which works great, but
I'm trying to retrieve this page using Apache HttpClient: http://quick-dish.tablespoon.com/ Unfortunately, when I try
I am trying to connect to a secure server using Apache Commons HttpClient 3.1
Hi i am using HttpClient similar to this: public static Task<string> AsyncStringRequest(string url, string
I'm reading a web page using HttpClient like this: httpclient = new DefaultHttpClient(); httpget
I'm using Apache HttpClient 3.x for contacting a Big IP that will then redirect
I have the following code which I use to send a request to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.