Re: how to make requests of http2 using curl

2019-12-17 Thread Dan Fandrich via curl-library
On Tue, Dec 17, 2019 at 02:44:11PM +0800, peng xu via curl-library wrote:
> curl_easy_setopt(easy_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);

You should really be checking the error codes returned by all these functions.
A failure here is a pretty big red flag.
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: how to make requests of http2 using curl

2019-12-16 Thread Ray Satiro via curl-library

On 12/17/2019 2:26 AM, Daniel Stenberg via curl-library wrote:

On Tue, 17 Dec 2019, peng xu via curl-library wrote:

I have wriiten the code below to make a http2 request, but the debug 
info showed me that it's http 1.1, would you please tell me why and 
how should I amend it:


Does your libcurl support HTTP/2 to begin with?


?? {
?? curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
?? printf("HTTP2 is %s\n", ((info->features & CURL_VERSION_HTTP2) ? 
"supported" : "NOT supported"));

?? printf("%s\n", curl_version());
?? }

---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: how to make requests of http2 using curl

2019-12-16 Thread Daniel Stenberg via curl-library

On Tue, 17 Dec 2019, peng xu via curl-library wrote:


curl_multi_setopt(easy_handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);


curl_multi_setopt() needs a *multi* handle in its first argument, not an easy 
handle. This is therefore a very bad line of code.


You can only do multiplexing with the multi interface in curl, since the easy 
interface makes a single transfer synchronously all the way until completed 
it can't multiplex.


--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Re: how to make requests of http2 using curl

2019-12-16 Thread Daniel Stenberg via curl-library

On Tue, 17 Dec 2019, peng xu via curl-library wrote:

I have wriiten the code below to make a http2 request, but the debug info 
showed me that it's http 1.1, would you please tell me why and how should I 
amend it:


Does your libcurl support HTTP/2 to begin with?

--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

how to make requests of http2 using curl

2019-12-16 Thread peng xu via curl-library
I have wriiten the code below to make a http2 request, but the debug info 
showed me that it's http 1.1, would you please tell me why and how should I 
amend it:
curl_global_init(CURL_GLOBAL_ALL);
CURL* easy_handle = curl_easy_init();
struct curl_slist* head = NULL;
char *form_data = "Content-Disposition: form-data; name=\"metadata\"";
head = curl_slist_append(head, form_data);
head = curl_slist_append(head, "Content-Type:application/json;charset=UTF-8");
curl_easy_setopt(easy_handle, CURLOPT_HTTPHEADER, head);
//curl_easy_setopt(easy_handle, CURLOPT_URL, "ai-test.xfyousheng.com:91");
curl_easy_setopt(easy_handle, CURLOPT_URL, "https://nghttp2.org/;);
curl_multi_setopt(easy_handle, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
curl_easy_setopt(easy_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);


curl_easy_setopt(easy_handle, CURLOPT_POSTFIELDS, request_json->data);
curl_easy_setopt(easy_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
data_chunk_t chunk;
chunk.data = malloc(1);  /* will be grown as needed by the realloc above */
chunk.size = 0;/* no data at this point */
curl_easy_setopt(easy_handle, CURLOPT_WRITEDATA, );
curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYPEER, 0L);//忽略证书检查
curl_easy_setopt(easy_handle, CURLOPT_SSL_VERIFYHOST, 0L);
/* please be verbose */
curl_easy_setopt(easy_handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(easy_handle, CURLOPT_DEBUGFUNCTION, my_trace);
CURLcode code;
code = curl_easy_perform(easy_handle);
long retcode = 0;
code = curl_easy_getinfo(easy_handle, CURLINFO_RESPONSE_CODE, );---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html