curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How to authenticate when using “CURLOPT_CONNECT_ONLY” so I can use non-blocking curl_easy_send() and curl_easy_recv()

From: Aleksander Mazur via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 19 Jul 2021 10:57:19 +0200

Dnia 2021-07-19, o godz. 03:38:27
Venkat Maddisetti via curl-library <curl-library_at_cool.haxx.se> napisał(a):

> To give some background, I am able to authenticate and able to work with the
> box with the blocked call ( without CURLOPT_CONNECT_ONLY option) with no
> control over the curl connection. The problem is, since the response from the
> box is a stream of data there is no way for me to stop the stream and send an
> another request. So from the documentation I figured out
> “CURLOPT_CONNECT_ONLY” is the way to go, and using the socket handle I can
> manage the communication to the box but after adding “CURLOPT_CONNECT_ONLY”
> option, I am not receiving the data stream as expected, I guess my request
> went through as there are no errors thrown, but looking closely I did not see
> authentication happening – I assume that is the problem, I am not doing
> anything fancy here just basic authentication only. Searched the web but
> could not get an answer and I am stuck. What am I missing here, does this
> option go in tandem with some other option I could not figure out or is there
> a different approach to authenticate while using this option.
>

Hi,

I think you should avoid using CURLOPT_CONNECT_ONLY and instead just use CURLOPT_WRITEFUNCTION to register a callback and process received data in it.
You can "stop the stream" (abort the connection) by returning a value different from the amount of data passed to the callback (according to https://curl.se/libcurl/c/CURLOPT_WRITEFUNCTION.html).

-- 
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2021-07-19