http2: add http2.[ch] and add nghttp2 version output
authorDaniel Stenberg <daniel@haxx.se>
Tue, 3 Sep 2013 21:17:06 +0000 (23:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 4 Sep 2013 20:29:38 +0000 (22:29 +0200)
lib/Makefile.inc
lib/http2.c [new file with mode: 0644]
lib/http2.h [new file with mode: 0644]
lib/version.c

index cb1030858270fb7bdb9d0d8a7326e4d54ec3757c..e60a4710519614884985c87095394079fa1ccb92 100644 (file)
@@ -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 (file)
index 0000000..8882f1f
--- /dev/null
@@ -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 (file)
index 0000000..4ad06c2
--- /dev/null
@@ -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 */
+
index 299e366258d5d3ffe1b077fbbada2a998defdb35..1f62131ebad928fd21c260d48c31186431098d36 100644 (file)
@@ -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];
@@ -274,6 +280,9 @@ static curl_version_info_data version_info = {
 #endif
 #if defined(USE_TLS_SRP)
   | CURL_VERSION_TLSAUTH_SRP
+#endif
+#if defined(USE_NGHTTP2)
+  | CURL_VERSION_HTTP2
 #endif
   ,
   NULL, /* ssl_version */