aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-09-03 23:17:06 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-09-04 22:29:38 +0200
commitac487842a18d77d31baee49a9dc022aa306b2ea1 (patch)
tree3a72adbe69a227684986332312a20a5b5ac74546 /lib
parent06b6e1d0d27dab4927f367afb9139ed5bf663153 (diff)
http2: add http2.[ch] and add nghttp2 version output
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.inc7
-rw-r--r--lib/http2.c39
-rw-r--r--lib/http2.h32
-rw-r--r--lib/version.c9
4 files changed, 84 insertions, 3 deletions
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index cb1030858..e60a47105 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -26,12 +26,12 @@ CSOURCES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c \
curl_sasl.c curl_schannel.c curl_multibyte.c curl_darwinssl.c \
hostcheck.c bundles.c conncache.c pipeline.c dotdot.c x509asn1.c \
- gskit.c
+ gskit.c http2.c
HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h \
if2ip.h speedcheck.h urldata.h curl_ldap.h ssluse.h escape.h telnet.h \
- getinfo.h strequal.h curl_sec.h memdebug.h http_chunks.h \
+ getinfo.h strequal.h curl_sec.h memdebug.h http_chunks.h \
curl_fnmatch.h wildcard.h fileinfo.h ftplistparser.h strtok.h \
connect.h llist.h hash.h content_encoding.h share.h curl_md4.h \
curl_md5.h http_digest.h http_negotiate.h inet_pton.h amigaos.h \
@@ -45,4 +45,5 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
asyn.h curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \
curl_ntlm_msgs.h curl_sasl.h curl_schannel.h curl_multibyte.h \
curl_darwinssl.h hostcheck.h bundles.h conncache.h curl_setup_once.h \
- multihandle.h setup-vms.h pipeline.h dotdot.h x509asn1.h gskit.h
+ multihandle.h setup-vms.h pipeline.h dotdot.h x509asn1.h gskit.h \
+ http2.c
diff --git a/lib/http2.c b/lib/http2.c
new file mode 100644
index 000000000..8882f1f80
--- /dev/null
+++ b/lib/http2.c
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2013, 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 http://curl.haxx.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.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef USE_NGHTTP2
+#include <nghttp2/nghttp2.h>
+#include "http2.h"
+
+/*
+ * Store nghttp2 version info in this buffer, Prefix with a space. Return
+ * total length written.
+ */
+int Curl_http2_ver(char *p, size_t len)
+{
+ nghttp2_info *h2 = nghttp2_version(0);
+ return snprintf(p, len, " nghttp2/%s", h2->version_str);
+}
+
+#endif
diff --git a/lib/http2.h b/lib/http2.h
new file mode 100644
index 000000000..4ad06c26d
--- /dev/null
+++ b/lib/http2.h
@@ -0,0 +1,32 @@
+#ifndef HEADER_CURL_HTTP2_H
+#define HEADER_CURL_HTTP2_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2013, 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 http://curl.haxx.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.
+ *
+ ***************************************************************************/
+
+/*
+ * Store nghttp2 version info in this buffer, Prefix with a space. Return
+ * total length written.
+ */
+int Curl_http2_ver(char *p, size_t len);
+
+#endif /* HEADER_CURL_HTTP2_H */
+
diff --git a/lib/version.c b/lib/version.c
index 299e36625..1f62131eb 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -25,6 +25,7 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sslgen.h"
+#include "http2.h"
#define _MPRINTF_REPLACE /* use the internal *printf() functions */
#include <curl/mprintf.h>
@@ -122,6 +123,11 @@ char *curl_version(void)
left -= len;
ptr += len;
#endif
+#ifdef USE_NGHTTP2
+ len = Curl_http2_ver(ptr, left);
+ left -= len;
+ ptr += len;
+#endif
#ifdef USE_LIBRTMP
{
char suff[2];
@@ -275,6 +281,9 @@ static curl_version_info_data version_info = {
#if defined(USE_TLS_SRP)
| CURL_VERSION_TLSAUTH_SRP
#endif
+#if defined(USE_NGHTTP2)
+ | CURL_VERSION_HTTP2
+#endif
,
NULL, /* ssl_version */
0, /* ssl_version_num, this is kept at zero */