[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 89/220: alt-svc: send Alt-Used: in redirected reque
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 89/220: alt-svc: send Alt-Used: in redirected requests |
Date: |
Thu, 12 Sep 2019 17:27:29 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 98c3f14871d1de77d1f9704e2f309aef9be33553
Author: Daniel Stenberg <address@hidden>
AuthorDate: Wed Aug 7 20:43:18 2019 +0200
alt-svc: send Alt-Used: in redirected requests
RFC 7838 section 5:
When using an alternative service, clients SHOULD include an Alt-Used
header field in all requests.
Removed CURLALTSVC_ALTUSED again (feature is still EXPERIMENTAL thus
this is deemed ok).
You can disable sending this header just like you disable any other HTTP
header in libcurl.
Closes #4199
---
docs/libcurl/symbols-in-versions | 1 -
include/curl/curl.h | 2 +-
lib/http.c | 16 ++++++++++++++--
lib/url.c | 1 +
lib/urldata.h | 1 +
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
index 9a4cec2b0..7897d7c2f 100644
--- a/docs/libcurl/symbols-in-versions
+++ b/docs/libcurl/symbols-in-versions
@@ -12,7 +12,6 @@
Name Introduced Deprecated Removed
-CURLALTSVC_ALTUSED 7.64.1
CURLALTSVC_H1 7.64.1
CURLALTSVC_H2 7.64.1
CURLALTSVC_H3 7.64.1
diff --git a/include/curl/curl.h b/include/curl/curl.h
index 14703fd17..7b02846b4 100644
--- a/include/curl/curl.h
+++ b/include/curl/curl.h
@@ -883,7 +883,7 @@ typedef enum {
/* CURLALTSVC_* are bits for the CURLOPT_ALTSVC_CTRL option */
#define CURLALTSVC_IMMEDIATELY (1<<0)
-#define CURLALTSVC_ALTUSED (1<<1)
+
#define CURLALTSVC_READONLYFILE (1<<2)
#define CURLALTSVC_H1 (1<<3)
#define CURLALTSVC_H2 (1<<4)
diff --git a/lib/http.c b/lib/http.c
index 546c34aad..73d52aee5 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1998,6 +1998,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
const char *httpstring;
Curl_send_buffer *req_buffer;
curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
+ char *altused = NULL;
/* Always consider the DO phase done after this function call, even if there
may be parts of the request that is not yet sent, since we can deal with
@@ -2592,6 +2593,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;
+#ifdef USE_ALTSVC
+ if(conn->bits.altused && !Curl_checkheaders(conn, "Alt-Used")) {
+ altused = aprintf("Alt-Used: %s:%d\r\n",
+ conn->conn_to_host.name, conn->conn_to_port);
+ if(!altused)
+ return CURLE_OUT_OF_MEMORY;
+ }
+#endif
result =
Curl_add_bufferf(&req_buffer,
"%s" /* ftp typecode (;type=x) */
@@ -2606,7 +2615,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
"%s" /* accept-encoding */
"%s" /* referer */
"%s" /* Proxy-Connection */
- "%s",/* transfer-encoding */
+ "%s" /* transfer-encoding */
+ "%s",/* Alt-Used */
ftp_typecode,
httpstring,
@@ -2632,13 +2642,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
!conn->bits.tunnel_proxy &&
!Curl_checkProxyheaders(conn, "Proxy-Connection"))?
"Proxy-Connection: Keep-Alive\r\n":"",
- te
+ te,
+ altused ? altused : ""
);
/* clear userpwd and proxyuserpwd to avoid re-using old credentials
* from re-used connections */
Curl_safefree(conn->allocptr.userpwd);
Curl_safefree(conn->allocptr.proxyuserpwd);
+ free(altused);
if(result)
return result;
diff --git a/lib/url.c b/lib/url.c
index 99bea3f01..d31f83065 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3187,6 +3187,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy
*data,
conn->bits.conn_to_host = TRUE;
conn->conn_to_port = nport;
conn->bits.conn_to_port = TRUE;
+ conn->bits.altused = TRUE;
infof(data, "Alt-svc connecting from [%s]%s:%d to [%s]%s:%d\n",
Curl_alpnid2str(salpnid), host, conn->remote_port,
Curl_alpnid2str(nalpnid), hostd, nport);
diff --git a/lib/urldata.h b/lib/urldata.h
index 395664d04..3129cb3ce 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -405,6 +405,7 @@ struct ConnectBits {
the first time on the first connect function call */
bit close:1; /* if set, we close the connection after this request */
bit reuse:1; /* if set, this is a re-used connection */
+ bit altused:1; /* this is an alt-svc "redirect" */
bit conn_to_host:1; /* if set, this connection has a "connect to host"
that overrides the host in the URL */
bit conn_to_port:1; /* if set, this connection has a "connect to port"
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [gnurl] 135/220: tests: Replace outdated test case numbering documentation, (continued)
- [GNUnet-SVN] [gnurl] 135/220: tests: Replace outdated test case numbering documentation, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 133/220: configure: use -lquiche to link to quiche, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 144/220: quiche: register debug callback once and earlier, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 138/220: RELEASE-NOTES: synced, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 140/220: vssh: create directory for SSH backend code, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 145/220: ngtcp2: move the h3 initing to immediately after the rx key, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 130/220: ngtcp2: deal with stream close, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 131/220: ngtcp2: add missing nghttp3_conn_add_write_offset call, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 132/220: ngtcp2: provide the callbacks as a static struct, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 85/220: curl: make use of CURLINFO_RETRY_AFTER when retrying, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 89/220: alt-svc: send Alt-Used: in redirected requests,
gnunet <=
- [GNUnet-SVN] [gnurl] 141/220: vssh: move ssh init/cleanup functions into backend code, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 114/220: CURLOPT_ALTSVC_CTRL.3: remove CURLALTSVC_ALTUSED, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 120/220: curl_version_info: make the quic_version a const, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 126/220: connect: connections are persistent by default for HTTP/3, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 134/220: travis: reduce number of torture tests in 'coverage', gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 150/220: configure: use pkg-config to detect quiche, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 129/220: ngtcp2: Consume QUIC STREAM data properly, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 137/220: travis: add a quiche build, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 149/220: CURLOPT_SSL_VERIFYHOST: treat the value 1 as 2, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 154/220: openssl: build warning free with boringssl, gnunet, 2019/09/12