Re: How to dry-run a http request

Peter Sylvester via curl-library <[email protected]>
Newsgroups gmane.comp.web.curl.library
Message-ID <[email protected]>
Hi, i
During my last eternity I used to make an entry in the /etc/hosts  pointing the URL host to 
localhost or even 127.0.0.n n>1
Thus, no mod necessary and you can have may servers on "localhost." provided you let then bind 
correctly.

Best

On 15/02/2025 16:21, Jeroen Ooms via curl-library wrote:
> For the R bindings, we have a popular debugging mode to 'dry-run' a
> http request. By this we mean that the user builds and performs a
> http-request in the regular way, but instead of actually connecting to
> the requested host, we trick libcurl to make the http request to a
> local server, which records the full payload that libcurl has
> uploaded, and we return this blob to the user.
>
> Currently the way this is implemented is a bit cumbersome. We first
> start a http-server in the background. Then we take the handle
> provided by the user, and replace CURLOPT_URL to substitute the host
> with "http://localhost". Then we modify CURLOPT_HTTPHEADER to set the
> 'Host' request header to the host:port that was specified by the user
> in the original url, and let libcurl perform the request. The fake
> server always returns 200.
>
> Especially the part where we need to run our own http server is a bit
> annoying. I was wondering if there would perhaps be a simpler method
> trick libcurl to send a http request to a local file or buffer, from
> where we can read it. Preferably something that we can do entirely in
> C (things like nc are difficult to port).


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.