Re: How to separate connection from request

2021-06-18 Thread Daniel Stenberg via curl-library

On Thu, 17 Jun 2021, 6dsovh35--- via curl-library wrote:

I'm trying to build a transport service that will maintain open connections 
to various services and send requests off as I receive them. I would like to 
build a curl session and connect it (including openssl handling) in my 
parent process and reuse that connection in my child process after it has 
been forked to actually send the request payload to the destination. I don't 
know what the request will be when I'm trying to open the connection so 
would like to keep from making a random curl_easy_perform that is likely to 
return an error. How can I accomplish this? I did stumble across a 
connect_only config that seemed like it would tell curl to only connect, but 
if I understand it correctly it then disables any reuse on that socket which 
is not what I'm after. Is what I'm seeking to do possible?


To me, this sounds like you want to do what I'd call "pre-connects". That is, 
connect to the server before you know if you want to issue a request to it, in 
order to have the request done faster later on if it indeed needs to be done.


libcurl doesn't have any (current) API that allows such connects without a 
request. The CONNECT_ONLY requests stops after the connect and that connection 
can't be reused again.


I have two suggestions on how to move forward:

1 - Issue a basic HEAD request and ignore the response. That's very little 
traffic so it almost achieves the same thing, just with some data back and 
forth as well.


2 - Introduce new functionality to libcurl that is a CONNECT_ONLY flavor that 
makes a normal connection left in the connection cache, possible to get reused 
in subsequent requests. Most of the logic should be the same as CONNECT_ONLY.


--

 / daniel.haxx.se
 | Commercial curl support up to 24x7 is available!
 | Private help, bug fixes, support, ports, new features
 | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

How to separate connection from request

2021-06-17 Thread 6dsovh35--- via curl-library
Hi!

I'm trying to build a transport service that will maintain open connections to 
various services and send requests off as I receive them. I would like to build 
a curl session and connect it (including openssl handling) in my parent process 
and reuse that connection in my child process after it has been forked to 
actually send the request payload to the destination. I don't know what the 
request will be when I'm trying to open the connection so would like to keep 
from making a random curl_easy_perform that is likely to return an error. How 
can I accomplish this?
I did stumble across a connect_only config that seemed like it would tell curl 
to only connect, but if I understand it correctly it then disables any reuse on 
that socket which is not what I'm after. Is what I'm seeking to do possible?

Thanks for your help!

---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html