aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2016-11-23 10:44:18 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-11-25 00:45:18 +0100
commitba410f6c64af26292d1dc549829c25af5602fbf7 (patch)
treec48cefe5f5626983fab185baeec1970a6c53f45f /lib
parent54789f94448e1a624f02cb4e4e739afe4a687656 (diff)
add CURLINFO_SCHEME, CURLINFO_PROTOCOL, and %{scheme}
Adds access to the effectively used protocol/scheme to both libcurl and curl, both in string and numeric (CURLPROTO_*) form. Note that the string form will be uppercase, as it is just the internal string. As these strings are declared internally as const, and all other strings returned by curl_easy_getinfo() are de-facto const as well, string handling in getinfo.c got const-ified. Closes #1137
Diffstat (limited to 'lib')
-rw-r--r--lib/connect.c2
-rw-r--r--lib/getinfo.c12
-rw-r--r--lib/urldata.h3
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 40252541f..c78d3da36 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -601,6 +601,8 @@ void Curl_persistconninfo(struct connectdata *conn)
{
memcpy(conn->data->info.conn_primary_ip, conn->primary_ip, MAX_IPADR_LEN);
memcpy(conn->data->info.conn_local_ip, conn->local_ip, MAX_IPADR_LEN);
+ conn->data->info.conn_scheme = conn->handler->scheme;
+ conn->data->info.conn_protocol = conn->handler->protocol;
conn->data->info.conn_primary_port = conn->primary_port;
conn->data->info.conn_local_port = conn->local_port;
}
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 7dcc71d33..4459a486b 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -86,7 +86,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
}
static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
- char **param_charp)
+ const char **param_charp)
{
switch(info) {
case CURLINFO_EFFECTIVE_URL:
@@ -123,6 +123,9 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
case CURLINFO_RTSP_SESSION_ID:
*param_charp = data->set.str[STRING_RTSP_SESSION_ID];
break;
+ case CURLINFO_SCHEME:
+ *param_charp = data->info.conn_scheme;
+ break;
default:
return CURLE_UNKNOWN_OPTION;
@@ -229,6 +232,9 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
break;
}
break;
+ case CURLINFO_PROTOCOL:
+ *param_longp = data->info.conn_protocol;
+ break;
default:
return CURLE_UNKNOWN_OPTION;
@@ -385,7 +391,7 @@ CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
va_list arg;
long *param_longp = NULL;
double *param_doublep = NULL;
- char **param_charp = NULL;
+ const char **param_charp = NULL;
struct curl_slist **param_slistp = NULL;
curl_socket_t *param_socketp = NULL;
int type;
@@ -399,7 +405,7 @@ CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
type = CURLINFO_TYPEMASK & (int)info;
switch(type) {
case CURLINFO_STRING:
- param_charp = va_arg(arg, char **);
+ param_charp = va_arg(arg, const char **);
if(param_charp)
result = getinfo_char(data, info, param_charp);
break;
diff --git a/lib/urldata.h b/lib/urldata.h
index 6e548285b..05f600319 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1174,6 +1174,9 @@ struct PureInfo {
char conn_local_ip[MAX_IPADR_LEN];
long conn_local_port;
+ const char *conn_scheme;
+ unsigned int conn_protocol;
+
struct curl_certinfo certs; /* info about the certs, only populated in
OpenSSL builds. Asked for with
CURLOPT_CERTINFO / CURLINFO_CERTINFO */