Skip to content

Commit bdeafae

Browse files
Merge pull request #4 from yinsidij/master
support HTTP put operation
2 parents d45f86e + c8f1191 commit bdeafae

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/winhttppal.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,14 +1983,25 @@ BOOLAPI WinHttpSendRequest
19831983
return FALSE;
19841984
}
19851985

1986-
request->SetOptionalData(lpOptional, dwOptionalLength);
1986+
if (!request->SetOptionalData(lpOptional, dwOptionalLength)) return FALSE;
19871987

19881988
if (request->GetType() == "POST")
19891989
{
19901990
/* Now specify the POST data */
19911991
res = curl_easy_setopt(request->GetCurl(), CURLOPT_POSTFIELDS, request->GetOptionalData().c_str());
19921992
CURL_BAILOUT_ONERROR(res, request, FALSE);
19931993
}
1994+
else if (request->GetType() == "PUT")
1995+
{
1996+
res = curl_easy_setopt(request->GetCurl(), CURLOPT_CUSTOMREQUEST, "PUT");
1997+
CURL_BAILOUT_ONERROR(res, request, FALSE);
1998+
1999+
res = curl_easy_setopt(request->GetCurl(), CURLOPT_POSTFIELDS, request->GetOptionalData().c_str()); // data goes here
2000+
CURL_BAILOUT_ONERROR(res, request, FALSE);
2001+
2002+
res = curl_easy_setopt(request->GetCurl(), CURLOPT_POSTFIELDSIZE, dwOptionalLength); // length is a must
2003+
CURL_BAILOUT_ONERROR(res, request, FALSE);
2004+
}
19942005
}
19952006

19962007
if (request->Uploading() || (request->GetType() == "POST"))

0 commit comments

Comments
 (0)