Hi Nirmal,

print(httpClient.responseText); writes the response back.

@Sajith I need to handle this from Jaggery side.

On Thu, Jul 9, 2015 at 3:41 PM, Sajith Ariyarathna <sajit...@wso2.com>
wrote:

> Hi Vinod,
>
> Can you use Java in the scenario? If so, then you can implement this task
> in Java and call that Java method inside your Jaggery code. I think
> implementing this task using Java will be lot easier.
>
> Thanks.
>
>
> On Thu, Jul 9, 2015 at 3:36 PM, Nirmal Fernando <nir...@wso2.com> wrote:
>
>> Where are you reading the chunked incoming data? I can't find it in the
>> code you pasted.
>>
>> So, the data is chunked and you have to read the data correctly. Spec:
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1
>>
>> On Thu, Jul 9, 2015 at 3:28 PM, Vinod Kavinda <vi...@wso2.com> wrote:
>>
>>> Hi,
>>> Thanks Inshaf. But this won't solve my problem. I have already done the
>>> downloading directly from browser, option. What I'm expecting is to get it
>>> to backend and then pass back to browser.
>>> This chunking is the problem.
>>>
>>> Regards,
>>> Vinod
>>>
>>> On Thu, Jul 9, 2015 at 3:18 PM, Inshaf Mahath <ins...@wso2.com> wrote:
>>>
>>>> Hi Vinod,
>>>>
>>>> Since you are using Jaggery, you can use JavaScript to create and
>>>> download a file. You can have a look on [1], but not sure whether it aligns
>>>> with your requirement.
>>>>
>>>> [1] -
>>>> http://blog.eliacontini.info/post/79860720828/export-to-csv-using-javascript-and-the-download
>>>>
>>>> Thanks,
>>>> Inshaf
>>>>
>>>>
>>>>
>>>> On Thu, Jul 9, 2015 at 1:49 PM, Vinod Kavinda <vi...@wso2.com> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I'm trying to download a file from a given URL (File get downloaded if
>>>>> we directly go to the link via browser), in a jaggery app.
>>>>>
>>>>> I need to get the file to the Jaggery backend and send it to the
>>>>> browser so that file should get downloaded. I tried this by sending a get
>>>>> request to the relevant URL, setting all the headers received from get
>>>>> response to the jaggery response and printing the payload as shown below.
>>>>>
>>>>>         var httpClient = new XMLHttpRequest();
>>>>>         httpClient.open('GET', url, true);
>>>>>         httpClient.setRequestHeader('COOKIE',
>>>>> session.get('MGT_SESSION'));
>>>>>
>>>>>          //copy header details
>>>>>                         var contentType =
>>>>> httpClient.getResponseHeader("Content-Type");
>>>>>         var transferEncoding =
>>>>> httpClient.getResponseHeader("Transfer-Encoding");
>>>>>         var vary = httpClient.getResponseHeader("Vary");
>>>>>         var date = httpClient.getResponseHeader("Date");
>>>>>         var server = httpClient.getResponseHeader("Server");
>>>>>         var contentDisposition =
>>>>> httpClient.getResponseHeader("Content-Disposition");
>>>>>
>>>>>         response.addHeader('Content-Type', contentType);
>>>>>         response.addHeader('Transfer-Encoding', transferEncoding);
>>>>>         response.addHeader('Vary', vary);
>>>>>         response.addHeader('Date', date);
>>>>>         response.addHeader('Server', server);
>>>>>         response.addHeader('Content-Disposition', contentDisposition);
>>>>>
>>>>>                         print(httpClient.responseText);
>>>>>
>>>>> A file get downloaded as expected. But is is a corrupted file with
>>>>> less size than actual size of the file.
>>>>>
>>>>> I think the reason for this is the data is coming as chunked data
>>>>> packets. The 'Transfer-Encoding' header value is 'chunked'.
>>>>>
>>>>> Any hint on resolving this is much appreciated.
>>>>>
>>>>> Thank You,
>>>>> Vinod
>>>>>
>>>>>
>>>>> --
>>>>> Vinod Kavinda
>>>>> Software Engineer
>>>>> *WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
>>>>> Mobile : +94 (0) 712 415544
>>>>> Blog : http://soatechflicks.blogspot.com/
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Inshaf Mahath
>>>>
>>>>
>>>
>>>
>>> --
>>> Vinod Kavinda
>>> Software Engineer
>>> *WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
>>> Mobile : +94 (0) 712 415544
>>> Blog : http://soatechflicks.blogspot.com/
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>>
>> Thanks & regards,
>> Nirmal
>>
>> Associate Technical Lead - Data Technologies Team, WSO2 Inc.
>> Mobile: +94715779733
>> Blog: http://nirmalfdo.blogspot.com/
>>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Sajith Ariyarathna
> Software Engineer; WSO2, Inc.;  http://wso2.com/
> mobile: +94 77 6602284, +94 71 3951048
>



-- 
Vinod Kavinda
Software Engineer
*WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
Mobile : +94 (0) 712 415544
Blog : http://soatechflicks.blogspot.com/
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to