Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

HttpClientRequest not returning the full response

Avatar

Avatar
Validate 1
Level 1
jferreira10
Level 1

Likes

2 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
jferreira10
Level 1

Likes

2 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
jferreira10
Level 1

28-05-2019

Hello,

My goal is to have a webform with a link for the client to download a PDF, this PDF should come from a HTTP request from a server in our network and I will display it via webform to the public.

I'm not able to receive the full response for a PDF on an HttpClientRequest, it seems that everytime the pdf is incomplete, if I try with a website URL the response is longer and ok, but never with PDF.

I've try all kinds of hearders but with no success.

Here's a sample of the code:

Code

var url = 'https://www.soundczech.cz/temp/lorem-ipsum.pdf';

var http = new HttpClientRequest(url);

http.method = "GET";

http.header["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36";

http.header["Accept"] = "application/pdf";

http.header["Content-Type"] = "application/pdf;charset=utf-8";

http.header["accept-encoding"] = "gzip, deflate";

http.execute();

logInfo(http.response.body);

pdf = http.response.body;;

The logInfo goes to web@default and the pdf is displayed on webpage.

Thanks for any help

View Entire Topic

Avatar

Avatar
Validate 1
Level 1
jferreira10
Level 1

Likes

2 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
jferreira10
Level 1

Likes

2 likes

Total Posts

8 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
jferreira10
Level 1

28-05-2019

I tried with a try catch but the end result is the same.

I have the same feeling, there should be a set of chars that ends the stream, be it in logInfo or displaying it in the page.

I think I'll have to try another approach.

I must read the PDF because we have it in a webserver in the network that is not public, so I need to grab the PDF and make it public.

Thank you for the help