cURL / Mailing Lists / curl-library / Single Mail


Unit tests with several responses

From: Joe Mason <>
Date: Fri, 20 Jul 2012 02:15:46 +0000

I'm trying to write a unit test for a bug with two auth requests. I want to send a Digest auth with the wrong password, and when I get back the 401, use curl_easy_reset on the handle and create a new request with the right password. I've written a test data file for this, with two <data> sections: a 401 response to send to the first request, and a 200 response to send to the second. The problem is, if I send a second request for the same url, the test server always sends back the 401 response.

I think what I want to do here is use the numbered data sections described in FILEFORMAT, but I don't understand the writeup. I've attached the two files I've got (test2023, the new test, and lib2023, a new tool to run for it). The tool should be pretty straightforward: send a request with CURLOPT_USERPWD set, and then send a second with it set to a different value. In the test file, I'm trying to use the explicit numbering:

Send back this contents instead of the <data> one. The num is set by:
A) The test number in the request line is >10000 and this is the remainder
of [test case number]%10000.

So I have sections <data1>, <data2>, <data3>, and in the <protocol> section, GET requests for /10001, /10002 and /10003. If I understand this right, it should send back the response in <data1> when it gets the request for /10001, etc. But I must not understand this, because when I run this, I get "server returned nothing (no headers, no data)". I also can't figure out how it interacts with

B) The request was HTTP and included digest details, which adds 1000 to NUM

and with swsbounce.

Little help?


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

List admin:

  • application/octet-stream attachment: test2023
Received on 2012-07-20