aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2016-05-11 14:23:37 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-05-30 22:58:51 +0200
commit071c56139463137a4e32a8d841a70c16f3682bb7 (patch)
tree8731f8c08ce57c019fa23eb4bf7bea72ded13314 /src
parent4bffaad85f7ba9ba12272a06ce4e4a81a9a3178a (diff)
http: add CURLINFO_HTTP_VERSION and %{http_version}
Adds access to the effectively used http version to both libcurl and curl. Closes #799
Diffstat (limited to 'src')
-rw-r--r--src/tool_writeout.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 414fcbea9..6e94afe42 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, 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
@@ -57,6 +57,7 @@ typedef enum {
VAR_PRIMARY_PORT,
VAR_LOCAL_IP,
VAR_LOCAL_PORT,
+ VAR_HTTP_VERSION,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@@ -95,6 +96,7 @@ static const struct variable replacements[]={
{"remote_port", VAR_PRIMARY_PORT},
{"local_ip", VAR_LOCAL_IP},
{"local_port", VAR_LOCAL_PORT},
+ {"http_version", VAR_HTTP_VERSION},
{NULL, VAR_NONE}
};
@@ -278,6 +280,26 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
&longinfo))
fprintf(stream, "%ld", longinfo);
break;
+ case VAR_HTTP_VERSION:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION,
+ &longinfo)) {
+ const char *version = "0";
+ switch (longinfo) {
+ case CURL_HTTP_VERSION_1_0:
+ version = "1.0";
+ break;
+ case CURL_HTTP_VERSION_1_1:
+ version = "1.1";
+ break;
+ case CURL_HTTP_VERSION_2_0:
+ version = "2";
+ break;
+ }
+
+ fprintf(stream, version);
+ }
+ break;
default:
break;
}