From: Sven Hoexter Date: Sun, 4 Sep 2016 14:47:19 +0000 (+0200) Subject: New upstream version 7.22.0+hg20160822 X-Git-Tag: upstream/7.22.0+hg20160822^0 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=2599beb367b4ac1cd1c517db000be5266edb6c81;p=sven%2Ftclcurl.git New upstream version 7.22.0+hg20160822 --- diff --git a/.hg_archival.txt b/.hg_archival.txt index 98a7ef7..f9ee621 100644 --- a/.hg_archival.txt +++ b/.hg_archival.txt @@ -1,5 +1,6 @@ repo: 11ea73a1b3c3793635669d40e602ff7f52f53e3a -node: b5bc0662447d3c92cc8d30e637e5a25457eac077 +node: 475f63137a7ecb3e8528e279ab66c0e59c16ab43 branch: default latesttag: null -latesttagdistance: 13 +latesttagdistance: 18 +changessincelatesttag: 19 diff --git a/doc/tclcurl.html b/doc/tclcurl.html index 5758241..9fe96c8 100755 --- a/doc/tclcurl.html +++ b/doc/tclcurl.html @@ -1244,6 +1244,18 @@ Enforce HTTP 1.0 requests.
Enforce HTTP 1.1 requests. +
2.0 + +
+Enforce HTTP version 2 requests. +
2TLS + +
+Enforce version 2 requests for HTTPS, version 1.1 for HTTP. +
2_PRIOR_KNOWLEDGE + +
+Enforce HTTP 2 requests without performing HTTP/1.1 Upgrade first. diff --git a/doc/tclcurl.n b/doc/tclcurl.n index 6e7227a..59fce53 100755 --- a/doc/tclcurl.n +++ b/doc/tclcurl.n @@ -1047,6 +1047,15 @@ Enforce HTTP 1.0 requests. .TP .B 1.1 Enforce HTTP 1.1 requests. +.TP +.B 2.0 +Enforce HTTP version 2 requests. +.TP +.B 2TLS +Enforce version 2 requests for HTTPS, version 1.1 for HTTP. +.TP +.B 2_PRIOR_KNOWLEDGE +Enforce HTTP 2 requests without performing HTTP/1.1 Upgrade first. .RE .TP diff --git a/generic/tclcurl.c b/generic/tclcurl.c index 21c947c..5e0a851 100755 --- a/generic/tclcurl.c +++ b/generic/tclcurl.c @@ -87,7 +87,7 @@ curlCreateObjCmd (Tcl_Interp *interp,struct curlObjData *curlData) { Tcl_Command cmdToken; /* We try with curl1, if it already exists with curl2...*/ - handleName=(char *)Tcl_Alloc(10); + handleName=(char *)Tcl_Alloc(32); for (i=1;;i++) { sprintf(handleName,"curl%d",i); if (!Tcl_GetCommandInfo(interp,handleName,&info)) { @@ -465,6 +465,12 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, case 1: Tcl_Free(curlData->outFile); curlData->outFile=curlstrdup(Tcl_GetString(objv)); + if (curlData->outFlag) { + if (curlData->outHandle!=NULL) { + fclose(curlData->outHandle); + curlData->outHandle=NULL; + } + } if ((strcmp(curlData->outFile,""))&&(strcmp(curlData->outFile,"stdout"))) { curlData->outFlag=1; } else { @@ -477,6 +483,12 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, case 2: Tcl_Free(curlData->inFile); curlData->inFile=curlstrdup(Tcl_GetString(objv)); + if (curlData->inFlag) { + if (curlData->inHandle!=NULL) { + fclose(curlData->inHandle); + curlData->inHandle=NULL; + } + } if ((strcmp(curlData->inFile,""))&&(strcmp(curlData->inFile,"stdin"))) { curlData->inFlag=1; } else { @@ -908,6 +920,13 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, case 44: Tcl_Free(curlData->headerFile); curlData->headerFile=curlstrdup(Tcl_GetString(objv)); + if (curlData->headerFlag) { + if (curlData->headerHandle!=NULL) { + fclose(curlData->headerHandle); + curlData->headerHandle=NULL; + } + curl_easy_setopt(curlHandle,CURLOPT_HEADERDATA,NULL); + } if ((strcmp(curlData->headerFile,""))&&(strcmp(curlData->headerFile,"stdout")) &&(strcmp(curlData->headerFile,"stderr"))) { curlData->headerFlag=1; @@ -1029,6 +1048,14 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, } break; case 61: + if (curlData->headerFlag) { + if (curlData->headerHandle!=NULL) { + fclose(curlData->headerHandle); + curlData->headerHandle=NULL; + } + curl_easy_setopt(curlHandle,CURLOPT_HEADERDATA,NULL); + curlData->headerFlag=0; + } if (curl_easy_setopt(curlHandle,CURLOPT_HEADERFUNCTION, curlHeaderReader)) { return TCL_ERROR; @@ -1043,6 +1070,14 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, case 62: Tcl_Free(curlData->bodyVarName); curlData->bodyVarName=curlstrdup(Tcl_GetString(objv)); + if (curlData->outFlag) { + if (curlData->outHandle!=NULL) { + fclose(curlData->outHandle); + curlData->outHandle=NULL; + } + curl_easy_setopt(curlHandle,CURLOPT_WRITEDATA,NULL); + } + curlData->outFlag=0; if (curl_easy_setopt(curlHandle,CURLOPT_WRITEFUNCTION, curlBodyReader)) { return TCL_ERROR; @@ -1080,6 +1115,13 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, break; case 65: curlData->writeProc=curlstrdup(Tcl_GetString(objv)); + if (curlData->outFlag) { + if (curlData->outHandle!=NULL) { + fclose(curlData->outHandle); + curlData->outHandle=NULL; + } + curl_easy_setopt(curlHandle,CURLOPT_WRITEDATA,NULL); + } curlData->outFlag=0; if (curl_easy_setopt(curlHandle,CURLOPT_WRITEFUNCTION, curlWriteProcInvoke)) { @@ -1093,6 +1135,13 @@ curlSetOpts(Tcl_Interp *interp, struct curlObjData *curlData, break; case 66: curlData->readProc=curlstrdup(Tcl_GetString(objv)); + if (curlData->inFlag) { + if (curlData->inHandle!=NULL) { + fclose(curlData->inHandle); + curlData->inHandle=NULL; + } + curl_easy_setopt(curlHandle,CURLOPT_READDATA,NULL); + } curlData->inFlag=0; if (strcmp(curlData->readProc,"")) { if (curl_easy_setopt(curlHandle,CURLOPT_READFUNCTION, @@ -2418,12 +2467,14 @@ curlHeaderReader(void *ptr,size_t size,size_t nmemb,FILE *curlDataPtr) { headerContent[charLength]=0; /* There may be multiple 'Set-Cookie' headers, so we use a list */ if (Tcl_StringCaseMatch(headerName,"Set-Cookie",1)) { - Tcl_SetVar2(curlData->interp,curlData->headerVar,headerName, \ + Tcl_SetVar2(curlData->interp,curlData->headerVar,headerName, headerContent,TCL_LIST_ELEMENT|TCL_APPEND_VALUE); } else { Tcl_SetVar2(curlData->interp,curlData->headerVar,headerName, headerContent,0); } + Tcl_Free(headerContent); + Tcl_Free(headerName); } regExp=Tcl_RegExpCompile(curlData->interp,"(^(HTTP|http)[^\r]+)(\r*)(\n)"); match=Tcl_RegExpExec(curlData->interp,regExp,header,header); @@ -2436,6 +2487,7 @@ curlHeaderReader(void *ptr,size_t size,size_t nmemb,FILE *curlDataPtr) { Tcl_SetVar2(curlData->interp,curlData->headerVar,"http", httpStatus,0); + Tcl_Free(httpStatus); } return size*nmemb; } @@ -4138,7 +4190,7 @@ curlCreateShareObjCmd (Tcl_Interp *interp,struct shcurlObjData *shcurlData) { Tcl_Command cmdToken; /* We try with scurl1, if it already exists with scurl2...*/ - shandleName=(char *)Tcl_Alloc(10); + shandleName=(char *)Tcl_Alloc(32); for (i=1;;i++) { sprintf(shandleName,"scurl%d",i); if (!Tcl_GetCommandInfo(interp,shandleName,&info)) { diff --git a/generic/tclcurl.h b/generic/tclcurl.h index acbee1f..b235d58 100755 --- a/generic/tclcurl.h +++ b/generic/tclcurl.h @@ -294,7 +294,13 @@ CONST static char *curlFormTable[]={ }; CONST static char *httpVersionTable[] = { - "none", "1.0", "1.1", (char *)NULL + "none", /* CURL_HTTP_VERSION_NONE */ + "1.0", /* CURL_HTTP_VERSION_1_0 */ + "1.1", /* CURL_HTTP_VERSION_1_1 */ + "2.0", /* CURL_HTTP_VERSION_2_0 */ + "2TLS", /* CURL_HTTP_VERSION_2TLS */ + "2_PRIOR_KNOWLEDGE", /* CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE */ + (char *)NULL }; CONST static char *netrcTable[] = {