Buy commercial curl support. 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 Daniel himself.
How to dry-run a http request
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Jeroen Ooms via curl-library <curl-library_at_lists.haxx.se>
Date: Sat, 15 Feb 2025 16:21:04 +0100
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).
Date: Sat, 15 Feb 2025 16:21:04 +0100
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.htmlReceived on 2025-02-15