Re: A string issue that after received the http 204, the curl_formadd function seems couldn't work again

2017-01-16 Thread Daniel Stenberg

On Tue, 17 Jan 2017, 杨俊 wrote:

Which I want is that I need re-use the curl_handle. But now, it seems if I 
got the 204, I can't use the same curl_handle again. Is my code wrong?


What exactly does it mean when you say you "can't use" it? What happens when 
you do?


--

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

non blocking ssl connections with NSS

2017-01-16 Thread Fahim Chandurwala
I see a commit here

that,
seems to me,  implements non blocking SSL handshaking for NSS.

But, on this page , under
"Blocking" section, it says:

A few areas in the code are still using blocking code..

- NSS SSL connections

I was thinking of migrating from OpenSSL to NSS, and this document was
preventing me from building libcurl with NSS.

Is the document outdated, or am I misunderstanding the intention of the
commit?
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Re: Removing */Makefile.vc[num] !

2017-01-16 Thread Daniel Stenberg

On Tue, 10 Jan 2017, Daniel Stenberg wrote:

I'd like to once again propose that we remove these makefiles in order to 
simplify and confuse our users less.


I'm attaching a patch showing what I'd like to do:


In spite of the ear-numbing silence on this topic, I've pushed a 
pull-request[1] and made a branch[2] available for testing. All and any 
comments welcome!


I'll merge this in seven days unless there's a compelling reason not to.

[1] = https://github.com/curl/curl/pull/1215
[2] = https://github.com/curl/curl/tree/remove-makefile-vc6

--

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

RE: proposed changes for winbuild makefile

2017-01-16 Thread Daniel Stenberg

On Mon, 16 Jan 2017, Kees Dekker wrote:

I propose the folling: curl always builds a static lib. And if a curl.dll is 
needed, then compile the dll from the previously generated static lib. 
Generating the static lib should not be more that adding all objects in one 
archive (similar to ar on UNIX).


Do you agree with that proposal? If agreed, I will file a different patch.


Again here, I'm hoping for someone who actually builds curl on Windows using 
the winbuild system to speak up on Kees' suggestions.


--

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

Re: proposed changes for winbuild makefile

2017-01-16 Thread Daniel Stenberg

On Mon, 16 Jan 2017, Kees Dekker wrote:


I've attached a patch to address some issues in the Windows build.


Somewhat related, we have an old outstanding pull request for another winbuild 
improvement that I would like a windows-build person to give thumbs up to 
before we can merge (mostly because I don't build on/know Windows myself):


  https://github.com/curl/curl/pull/730

--

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

RE: proposed changes for winbuild makefile

2017-01-16 Thread Kees Dekker
The patch is stull insufficient. The difficulty is that the makefile combines 
building curl.dll (in one step) and libcurl_a.lib (static) as one single step.
This is funny to build curl.exe, but not funny if the static lib is used for 
other purposes. The current build procedure adds all objects (including zlib, 
libssh2, openSSL etc) to a single .lib file, omitting the pdb files, and 
resulting in LNK4099 warnings/errors, because the pdb files of the used 
products are not aggregated. The resulting static curl lib is about 30MB, far 
more that the aggregation of the curl objects.

I propose the folling: curl always builds a static lib. And if a curl.dll is 
needed, then compile the dll from the previously generated static lib. 
Generating the static lib should not be more that adding all objects in one 
archive (similar to ar on UNIX).

Do you agree with that proposal? If agreed, I will file a different patch.

From: curl-library [mailto:curl-library-boun...@cool.haxx.se] On Behalf Of Kees 
Dekker
Sent: Monday, January 16, 2017 09:32
To: curl-library@cool.haxx.se
Subject: proposed changes for winbuild makefile

Hi,

I've attached a patch to address some issues in the Windows build.
See also https://github.com/curl/curl/issues/1201#issuecomment-272394593.
Based on the advice of Daniel, I switched away from Visual Studio version 
dependent lib\Makefile.vc to the (recommended) winbuild\Makefile.vc 
procedure.
I had to solve some things to be able to build curl with zlib, libssh2 and 
openSSL libraries at a different location, and with different names.

The patch tries to address the following issues:

-  When using USE_PDB, conflicting flags (/Z7 and /Zi) are provided to 
the Visual Studio compiler of a Visual Studio version > 6 was used. A PDB file 
is only generated for libcurl/curl.dll, not for the curl.exe.

-  The openSSL libraries have been renamed as of openSSL 1.1.0x. I 
added some makefile variables that allow to override the library names. The 
default assumptions of the MakefileBuild.vc are not (always) correct (e.g. 
libz_a.lib, which is in fact libz.a). Also compiler and linker flags can be 
overridden by using DEVEL_CFLAGS and/or DEVEL_LFLAGS variables.
An example of calling the make is: nmake -f Makefile.vc mode=static VC=14 
WITH_SSL=static WITH_ZLIB=static WITH_SSH2=static GEN_PDB=yes DEBUG=no 
MACHINE=x64 SSL_CFLAGS="/I$(OpenSSLIncDir)" ZLIB_CFLAGS="/I$(ZlibIncDir)" 
SSH2_CFLAGS="/I$(Libssh2IncDir)" SSL_LIBS="libcrypto.lib libssl.lib" 
ZLIB_LIBS=zlib.lib SSH2_LIBS=libssh2.lib 
DEVEL_LFLAGS="/LIBPATH:$(OpenSSLLibDir) /LIBPATH:$(ZlibLibDir) 
/LIBPATH:$(Libssh2LibDir)". The $(xxx) are variables that point to the actual 
include and library paths.

-  There was no clean target in Makefile.vc. And the clean target in 
MakefileBuild.vc was unreachable, due to some tests. This has been fixed, and 
nmake -f Makefile.vc mode=static clean now works.

-  Minor cleanup in MakefileBuild.vc: DEVEL_BIN was not used.

The attached patch has been tested with static libz, libssh2 and openSSL 
libraries to build 32-bit and 64-bit optimized + debug curl DLL and curl static 
libs + curl.exe. If no makefile variables are specified to override libraries 
names and/or include or library paths, then the defaults fall back to the 
original behavior.

This is my first contribution to this mailing list. Not sure whether all 
information is provided. The patch is in *NIX style format and can be applied 
by using the patch tool.

Regards,
Kees Dekker



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

A string issue that after received the http 204, the curl_formadd function seems couldn't work again

2017-01-16 Thread 杨俊
Hi guys,

Currently, I used the libcurl7.51.0+openssl+nghttp2 to do my work.
I used the multi_handles and curl_formadd.
When the demo do a POST and get a http 200 result, then I can do a POST
again and again.
(the POST message need the curl_formadd)
But if the demo get the http 204 result after the POST, then I can't do the
POST again.
It seemed that the POST's message can't be upload(the curl_formadd seems
didn't work).
Please help.
-this is my code
snippet---
static void curl_ping_cfg(CURL *curl, struct curl_slist *head, char *auth)
{
CURLcode res;

/* set the opt */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0 );
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl, CURLOPT_CAINFO, "/tmp/cacert.pem");

/* set the head */
head = curl_slist_append(head , DEL_HTTPHEAD_ACCEPT);
head = curl_slist_append(head , "Path: /ping");
head = curl_slist_append(head , auth);
head = curl_slist_append(head , "Host: avs-alexa-na.amazon.com");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, head);
if (res != CURLE_OK){
printf("%s: curl_easy_setopt failed: %s\n", __FUNCTION__,
curl_easy_strerror(res));
}

/* set the url */
curl_easy_setopt(curl, CURLOPT_URL, "https://avs-alexa-na.amazon.com/ping;);

/* set the GET */
// curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);

}

static void curl_sync_state(CURL *curl, char *strJSONout,
 struct curl_httppost *postFirst,
 struct curl_httppost *postLast)
{

printf("%s\n%ld\n", strJSONout, strlen(strJSONout));

/*curl set the formadd  */
/* JSON  */
curl_formadd(, ,
CURLFORM_COPYNAME, "metadata", /* CURLFORM_PTRCONTENTS, pAlexaJSON,  */
CURLFORM_COPYCONTENTS, strJSONout,
CURLFORM_CONTENTTYPE, "application/json; charset=UTF-8",
CURLFORM_END);

/* set http post */
curl_easy_setopt(curl, CURLOPT_HTTPPOST, postFirst);

}

static void curl_send_audio_content(CURL *curl, char *strJSONout,
struct curl_httppost *postFirst,
struct curl_httppost *postLast)
{

printf("%s\n%ld\n", strJSONout, strlen(strJSONout));

/* formadd */

//josn//
curl_formadd(, ,
CURLFORM_COPYNAME, "metadata", /* CURLFORM_PTRCONTENTS, pAlexaJSON,  */
CURLFORM_COPYCONTENTS, strJSONout,
CURLFORM_CONTENTTYPE, "application/json; charset=UTF-8",
CURLFORM_END);

//=Audio=//
curl_formadd(, ,
CURLFORM_COPYNAME, "audio",
CURLFORM_STREAM, ,
CURLFORM_CONTENTTYPE, "application/octet-stream", //"audio/L16; rate=16000;
channels=1",
CURLFORM_END);



/* set http post */
curl_easy_setopt(curl, CURLOPT_HTTPPOST, postFirst);

}


static void curl_send_audio_cfg(CURL *curl, struct curl_slist *head, char
*auth)
{
/* set the opt */
curl_easy_setopt(curl , CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl , CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0 );
curl_easy_setopt(curl , CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl , CURLOPT_CAINFO, "/tmp/cacert.pem");

/* set the head */
head = curl_slist_append(head , DEL_HTTPHEAD_ACCEPT);
head = curl_slist_append(head , DEL_HTTPHEAD_EXPECT);
head = curl_slist_append(head , "Path: /v20160207/events");
head = curl_slist_append(head , auth);
head = curl_slist_append(head , "Content-type: multipart/form-data" );
head = curl_slist_append(head , "Transfer-Encoding: chunked");
head = curl_slist_append(head , "Host: avs-alexa-na.amazon.com");

/* set the url */
curl_easy_setopt(curl, CURLOPT_URL, "
https://avs-alexa-na.amazon.com/v20160207/events;);//v20160207/events
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, head);

curl_easy_setopt(curl, CURLOPT_READFUNCTION,
readFileFunc);设置读文件函数接口
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, WriteMemoryCallback);
 //CURLOPT_WRITEFUNCTION 将后继的动作交给write_data函数处理
curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_send_audio_callback);
 //CURLOPT_WRITEFUNCTION 将后继的动作交给write_data函数处理
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *));

}

static void curl_downchannel_cfg(CURL *curl, struct curl_slist *head, char
*auth)
{
CURLcode res;

/* set the opt */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
curl_easy_setopt(curl, CURLOPT_CAINFO, "/tmp/cacert.pem");

/* set the head */
head = curl_slist_append(head , DEL_HTTPHEAD_ACCEPT);
head = curl_slist_append(head , "Path: /v20160207/directives");
head = curl_slist_append(head , auth);
head = curl_slist_append(head , "Host: avs-alexa-na.amazon.com");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, head);
if (res != CURLE_OK){
printf("%s: curl_easy_setopt failed: %s\n",
__FUNCTION__,curl_easy_strerror(res));
}

/* set the url */
curl_easy_setopt(curl, CURLOPT_URL, "
https://avs-alexa-na.amazon.com/v20160207/directives;);

/* send all data to this function  */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 

proposed changes for winbuild makefile

2017-01-16 Thread Kees Dekker
Hi,

I've attached a patch to address some issues in the Windows build.
See also https://github.com/curl/curl/issues/1201#issuecomment-272394593.
Based on the advice of Daniel, I switched away from Visual Studio version 
dependent lib\Makefile.vc to the (recommended) winbuild\Makefile.vc 
procedure.
I had to solve some things to be able to build curl with zlib, libssh2 and 
openSSL libraries at a different location, and with different names.

The patch tries to address the following issues:

-  When using USE_PDB, conflicting flags (/Z7 and /Zi) are provided to 
the Visual Studio compiler of a Visual Studio version > 6 was used. A PDB file 
is only generated for libcurl/curl.dll, not for the curl.exe.

-  The openSSL libraries have been renamed as of openSSL 1.1.0x. I 
added some makefile variables that allow to override the library names. The 
default assumptions of the MakefileBuild.vc are not (always) correct (e.g. 
libz_a.lib, which is in fact libz.a). Also compiler and linker flags can be 
overridden by using DEVEL_CFLAGS and/or DEVEL_LFLAGS variables.
An example of calling the make is: nmake -f Makefile.vc mode=static VC=14 
WITH_SSL=static WITH_ZLIB=static WITH_SSH2=static GEN_PDB=yes DEBUG=no 
MACHINE=x64 SSL_CFLAGS="/I$(OpenSSLIncDir)" ZLIB_CFLAGS="/I$(ZlibIncDir)" 
SSH2_CFLAGS="/I$(Libssh2IncDir)" SSL_LIBS="libcrypto.lib libssl.lib" 
ZLIB_LIBS=zlib.lib SSH2_LIBS=libssh2.lib 
DEVEL_LFLAGS="/LIBPATH:$(OpenSSLLibDir) /LIBPATH:$(ZlibLibDir) 
/LIBPATH:$(Libssh2LibDir)". The $(xxx) are variables that point to the actual 
include and library paths.

-  There was no clean target in Makefile.vc. And the clean target in 
MakefileBuild.vc was unreachable, due to some tests. This has been fixed, and 
nmake -f Makefile.vc mode=static clean now works.

-  Minor cleanup in MakefileBuild.vc: DEVEL_BIN was not used.

The attached patch has been tested with static libz, libssh2 and openSSL 
libraries to build 32-bit and 64-bit optimized + debug curl DLL and curl static 
libs + curl.exe. If no makefile variables are specified to override libraries 
names and/or include or library paths, then the defaults fall back to the 
original behavior.

This is my first contribution to this mailing list. Not sure whether all 
information is provided. The patch is in *NIX style format and can be applied 
by using the patch tool.

Regards,
Kees Dekker





makefile.win.patch
Description: makefile.win.patch
---
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

build curl.1

2017-01-16 Thread Daniel Stenberg

Hey,

I've now filed a pull-request [1] that removes docs/curl.1 from git, and 
instead automatically generate it as part of the build procedure. It is also 
available to try out in the new 'generate-curl-1' branch [2].


We already generate the man page since a few weeks back so that's not the 
news. The news is that we now have it depending on the components properly so 
if you update the description of a single option, the man page gets remade 
accordingly.


And as it is generally bad form and inconvenient to host generated files in 
git, I would like to remove it from there. (Note: it will still be present as 
docs/curl.1 in release tarballs, just like before.)


But...

I've only fixed the autotools based build procedure so this will break all 
other builds. I'm very interested in getting help with and feedback on how to 
fix the other builds. In particular the cmake one and windows specific builds 
(as I believe they're used fairly widely).


[1] = https://github.com/curl/curl/pull/1214
[2] = https://github.com/curl/curl/tree/generate-curl-1

--

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