-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libtest: 2308 verifies CURLE_WRITE_ERROR after write callback error
Verifies that the issue in #13669 actually is fixed. This return code is what the CURLOPT_WRITEFUNCTION manpage documents should be returned. This code is mostly from the Source-written-by: Trumeet on github Closes #13671
- Loading branch information
Showing
4 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<testcase> | ||
<info> | ||
<keywords> | ||
HTTP | ||
HTTP GET | ||
</keywords> | ||
</info> | ||
# | ||
# This reproduces the #13669 issue | ||
<reply> | ||
<data nocheck="yes"> | ||
HTTP/1.1 200 OK | ||
Date: Tue, 09 Nov 2010 14:49:00 GMT | ||
Server: test-server/fake | ||
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT | ||
ETag: "21025-dc7-39462498" | ||
Accept-Ranges: bytes | ||
Content-Length: 6 | ||
Content-Type: text/html | ||
Funny-head: yesyes | ||
|
||
-foo- | ||
</data> | ||
</reply> | ||
|
||
# Client-side | ||
<client> | ||
<server> | ||
http | ||
</server> | ||
# tool to run | ||
<tool> | ||
lib%TESTNUMBER | ||
</tool> | ||
|
||
<name> | ||
verify return code when write callback returns error | ||
</name> | ||
<command> | ||
http://%HOSTIP:%HTTPPORT/%TESTNUMBER | ||
</command> | ||
</client> | ||
|
||
# | ||
# Verify data after the test has been "shot" | ||
<verify> | ||
<protocol> | ||
GET /%TESTNUMBER HTTP/1.1 | ||
Host: %HOSTIP:%HTTPPORT | ||
Accept: */* | ||
|
||
</protocol> | ||
<stdout mode="text"> | ||
Returned 23, should be 23. | ||
</stdout> | ||
</verify> | ||
</testcase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*************************************************************************** | ||
* _ _ ____ _ | ||
* Project ___| | | | _ \| | | ||
* / __| | | | |_) | | | ||
* | (__| |_| | _ <| |___ | ||
* \___|\___/|_| \_\_____| | ||
* | ||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. | ||
* | ||
* This software is licensed as described in the file COPYING, which | ||
* you should have received as part of this distribution. The terms | ||
* are also available at https://curl.se/docs/copyright.html. | ||
* | ||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
* copies of the Software, and permit persons to whom the Software is | ||
* furnished to do so, under the terms of the COPYING file. | ||
* | ||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
* KIND, either express or implied. | ||
* | ||
* SPDX-License-Identifier: curl | ||
* | ||
***************************************************************************/ | ||
|
||
#include "test.h" | ||
#include "testtrace.h" | ||
|
||
#include <curl/curl.h> | ||
|
||
static size_t cb_curl(void *buffer, size_t size, size_t nmemb, void *userp) | ||
{ | ||
(void)buffer; | ||
(void)size; | ||
(void)nmemb; | ||
(void)userp; | ||
return CURL_WRITEFUNC_ERROR; | ||
} | ||
|
||
CURLcode test(char *URL) | ||
{ | ||
CURL *curl; | ||
CURLcode res = CURLE_OK; | ||
|
||
global_init(CURL_GLOBAL_ALL); | ||
curl = curl_easy_init(); | ||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb_curl); | ||
curl_easy_setopt(curl, CURLOPT_URL, URL); | ||
res = curl_easy_perform(curl); | ||
printf("Returned %d, should be %d.\n", res, CURLE_WRITE_ERROR); | ||
fflush(stdout); | ||
curl_easy_cleanup(curl); | ||
curl_global_cleanup(); | ||
return CURLE_OK; | ||
} |