cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to separate two different response

From: smruti kumari <smrutikumari777_at_gmail.com>
Date: Wed, 18 May 2016 12:05:16 +0530

Hi Ray,

Thanks for your quick reply.
Let's consider I have two enpoints E1, E2 and one server. E1 send a request
to server and server forward to E2. E2 gives two responses to E1 via
server.If these two response come together(one after another) then how can
I separte it these two response since it's a stream?

when one respose finish and other respose started in write callback ?

Thanks,
Smruti

On Tue, May 17, 2016 at 11:46 PM, Ray Satiro via curl-library <
curl-library_at_cool.haxx.se> wrote:

> On 5/17/2016 3:20 AM, smruti kumari wrote:
>
>>
>> I am sending a http request and adding josn data in the body.Similary
>> server also responding with json body.The response packet we will recv in
>> the write callback.But my query is
>>
>> How can we come to know that how much bytes I need to receive for the
>> particualr response ?
>>
>
> Can you be more specific? The write function is passed as much data as
> available when it's called [1]. It will likely be called multiple times,
> each time with a piece of the reply. It's up to your callback to append
> those pieces. Take a look at the getinmemory example [2]. When you say
> server response packet what do you mean? Do you mean you have received two
> server replies or your write callback has been called twice? Those are two
> different things.
>
>
> [1]: https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
> [2]: https://curl.haxx.se/libcurl/c/getinmemory.html
>
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-18