0

I am using proxygen and need to get the body of a HTTP "GET" request. I have to use the curlclient provided in the sample httpclient. Now, I have to use the present api of the library. But the curlclient is based on 2 classes: HTTPConnector and HTTPTransaction. Both of them dont have any function that I have found that can return body of the message. So, is there a way to do so? How can I do this?

EDIT: Thanks, I found it and got it working. Now I need to parse the JSON I got. I have written this :

folly::fbstring body;
body = curlClient.getBody();

folly::dynamic parsed_body =  folly::parseJson(body);

but it is throwing error on the gdb on the third line. what could be the reason?

error:

Program received signal SIGABRT, Aborted.
0x00007ffff6741c37 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
daenerys
  • 63
  • 1
  • 6
  • You do know that having a body with a `GET` request goes against the recommendations in the HTTP/1.1 spec don't you? If you're in control of the client and server then you ought to consider a different method. – Andy Brown Jun 24 '16 at 14:11
  • @AndyBrown you are right that a `GET` **request** does not have a body. But the OP is running client-side, not server-side, so is likely asking how to send an HTTP `GET` request and then read the body of the **response** (otherwise what is the point in sending the request?). – Remy Lebeau Jun 24 '16 at 15:27
  • Yes that's it. Now I've tried the httpconnector and httptransactionhandler classes too. I haven't been able to get a solution. – daenerys Jun 24 '16 at 16:11
  • You'll have to implement something in the 'onBody' member of CurlClient. – kfsone Jun 24 '16 at 23:29
  • @kfsone Please see the edit – daenerys Jun 25 '16 at 02:12

0 Answers0