mirror of
https://github.com/curl/curl.git
synced 2026-07-09 04:47:17 +03:00
first draft
formating Co-authored-by: Viktor Szakats <vszakats@users.noreply.github.com> Update lib/url.c Co-authored-by: Viktor Szakats <vszakats@users.noreply.github.com> Update docs/libcurl/opts/CURLOPT_ALTSVC_CTRL.md Co-authored-by: Daniel Stenberg <daniel@haxx.se>
This commit is contained in:
parent
0a96b878f7
commit
01603f988e
6 changed files with 106 additions and 4 deletions
|
|
@ -26,6 +26,7 @@ CURLOPT_ALTSVC_CTRL - control alt-svc behavior
|
|||
#define CURLALTSVC_H1 (1L<<3)
|
||||
#define CURLALTSVC_H2 (1L<<4)
|
||||
#define CURLALTSVC_H3 (1L<<5)
|
||||
#define CURLALTSVC_NO_RETRY (1L<<6)
|
||||
|
||||
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_ALTSVC_CTRL, long bitmask);
|
||||
~~~
|
||||
|
|
@ -51,6 +52,11 @@ versions.
|
|||
|
||||
Setting any bit enables the alt-svc engine.
|
||||
|
||||
If the connection fails when trying to connect to an alternative host,
|
||||
the hostname from the URL is attempted instead.
|
||||
|
||||
Failed connection problems that trigger this fallback include: ...
|
||||
|
||||
## CURLALTSVC_READONLYFILE
|
||||
|
||||
Do not write the alt-svc cache back to the file specified with
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ CURLALTSVC_H1 7.64.1
|
|||
CURLALTSVC_H2 7.64.1
|
||||
CURLALTSVC_H3 7.64.1
|
||||
CURLALTSVC_READONLYFILE 7.64.1
|
||||
CURLALTSVC_NO_RETRY 8.14.0
|
||||
CURLAUTH_ANY 7.10.6
|
||||
CURLAUTH_ANYSAFE 7.10.6
|
||||
CURLAUTH_AWS_SIGV4 7.75.0
|
||||
|
|
|
|||
|
|
@ -1032,6 +1032,7 @@ typedef enum {
|
|||
#define CURLALTSVC_H1 (1L<<3)
|
||||
#define CURLALTSVC_H2 (1L<<4)
|
||||
#define CURLALTSVC_H3 (1L<<5)
|
||||
#define CURLALTSVC_NO_RETRY (1L<<6)
|
||||
|
||||
/* bitmask values for CURLOPT_UPLOAD_FLAGS */
|
||||
#define CURLULFLAG_ANSWERED (1L<<0)
|
||||
|
|
|
|||
37
lib/url.c
37
lib/url.c
|
|
@ -3426,7 +3426,9 @@ static void conn_meta_freeentry(void *p)
|
|||
|
||||
static CURLcode create_conn(struct Curl_easy *data,
|
||||
struct connectdata **in_connect,
|
||||
bool *reusedp)
|
||||
bool *reusedp,
|
||||
bool *async,
|
||||
bool *use_slist)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct connectdata *conn;
|
||||
|
|
@ -3537,9 +3539,12 @@ static CURLcode create_conn(struct Curl_easy *data,
|
|||
* Process the "connect to" linked list of hostname/port mappings.
|
||||
* Do this after the remote port number has been fixed in the URL.
|
||||
*************************************************************/
|
||||
result = parse_connect_to_slist(data, conn, data->set.connect_to);
|
||||
if(result)
|
||||
goto out;
|
||||
if(*use_slist) {
|
||||
*use_slist = FALSE; /* next retry without slist */
|
||||
result = parse_connect_to_slist(data, conn, data->set.connect_to);
|
||||
if(result)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* IDN-convert the proxy hostnames
|
||||
|
|
@ -3851,7 +3856,11 @@ CURLcode Curl_connect(struct Curl_easy *data,
|
|||
{
|
||||
CURLcode result;
|
||||
struct connectdata *conn;
|
||||
<<<<<<< HEAD
|
||||
bool reused = FALSE;
|
||||
=======
|
||||
bool use_slist = TRUE; /* start by attempting to use the slist */
|
||||
>>>>>>> 3edfc1476 (first draft)
|
||||
|
||||
*asyncp = FALSE; /* assume synchronous resolves by default */
|
||||
*protocol_done = FALSE;
|
||||
|
|
@ -3860,12 +3869,32 @@ CURLcode Curl_connect(struct Curl_easy *data,
|
|||
Curl_req_hard_reset(&data->req, data);
|
||||
|
||||
/* call the stuff that needs to be called */
|
||||
<<<<<<< HEAD
|
||||
result = create_conn(data, &conn, &reused);
|
||||
|
||||
if(result == CURLE_NO_CONNECTION_AVAILABLE) {
|
||||
DEBUGASSERT(!conn);
|
||||
return result;
|
||||
}
|
||||
=======
|
||||
result = create_conn(data, &conn, asyncp, &use_slist);
|
||||
|
||||
#ifndef CURL_DISABLE_ALTSVC
|
||||
/* if we failed because of the avc cache retry */
|
||||
if(result && data-> asi
|
||||
&& !use_slist
|
||||
&& !(data-> asi-> flags & CURLALTSVC_NO_RETRY)
|
||||
) {
|
||||
if(conn && result != CURLE_NO_CONNECTION_AVAILABLE) {
|
||||
Curl_detach_connection(data);
|
||||
Curl_conn_terminate(data, conn, TRUE);
|
||||
}
|
||||
|
||||
Curl_req_hard_reset(&data->req, data);
|
||||
result = create_conn(data, &conn, asyncp, &use_slist);
|
||||
}
|
||||
#endif
|
||||
>>>>>>> 3edfc1476 (first draft)
|
||||
|
||||
if(!result) {
|
||||
DEBUGASSERT(conn);
|
||||
|
|
|
|||
|
|
@ -280,5 +280,7 @@ test3100 test3101 test3102 test3103 test3104 test3105 \
|
|||
test3200 test3201 test3202 test3203 test3204 test3205 test3207 test3208 \
|
||||
test3209 test3210 test3211 test3212 test3213 test3214 test3215 \
|
||||
test4000 test4001
|
||||
test3209 test3210 test3211 test3212 test3213 test3214 \
|
||||
test3300
|
||||
|
||||
EXTRA_DIST = $(TESTCASES) DISABLED
|
||||
|
|
|
|||
63
tests/data/test3300
Normal file
63
tests/data/test3300
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
HTTP GET
|
||||
Alt-Svc
|
||||
onion
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||
Content-Length: 6
|
||||
Connection: close
|
||||
Content-Type: text/html
|
||||
Funny-head: yesyes
|
||||
|
||||
-foo-
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
alt-svc
|
||||
Debug
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<name>
|
||||
alt-svc using to an onion server
|
||||
</name>
|
||||
<setenv>
|
||||
# make debug-curl accept Alt-Svc over plain HTTP
|
||||
CURL_ALTSVC_HTTP="yeah"
|
||||
</setenv>
|
||||
<command>
|
||||
--alt-svc "%LOGDIR/altsvc-%TESTNUMBER" "http://%HOSTIP:%HTTPPORT/%TESTNUMBER"
|
||||
</command>
|
||||
<file name="%LOGDIR/altsvc-%TESTNUMBER">
|
||||
h1 %HOSTIP %HTTPPORT h1 bad.onion %HTTPPORT "20290222 22:19:28" 0 0
|
||||
</file>
|
||||
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
GET /%TESTNUMBER HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
User-Agent: curl/%VERSION
|
||||
Accept: */*
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue