This patch was merged from WineX's LGPLed wininet code, but I haven't tested it. Thanks to David for spotting an error in the previous patch.
Mike
ChangeLog: David Hammerton <david@transgaming.com> * add support for http-POST. (well, any kind of http request that sends data in the lpOptional field)
Index: dlls/wininet/http.c =================================================================== RCS file: /home/wine/wine/dlls/wininet/http.c,v retrieving revision 1.38 diff -u -r1.38 http.c --- dlls/wininet/http.c 22 Jul 2003 03:17:52 -0000 1.38 +++ dlls/wininet/http.c 4 Aug 2003 10:27:51 -0000 @@ -940,7 +940,8 @@ LPWININETHTTPSESSIONA lpwhs = NULL; LPWININETAPPINFOA hIC = NULL; - TRACE("0x%08lx\n", (unsigned long)hHttpRequest); + TRACE("(0x%08lx, %p (%s), %li, %p, %li)\n", (unsigned long)hHttpRequest, + lpszHeaders, debugstr_a(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength); if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ) { @@ -1192,6 +1193,14 @@ goto lend; } + /* if we are using optional stuff, we must add the fixed header of that option length */ + if (lpOptional && dwOptionalLength) + { + char contentLengthStr[strlen("Content-Length: ") + 20 /* int */ + 2 /* \n\r */]; + sprintf(contentLengthStr, "Content-Length: %li\r\n", dwOptionalLength); + HttpAddRequestHeadersA(hHttpRequest, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD); + } + do { TRACE("Going to url %s %s\n", debugstr_a(lpwhr->lpszHostName), debugstr_a(lpwhr->lpszPath)); @@ -1255,6 +1264,11 @@ if (lpwhr->lpszHostName) requestStringLen += (strlen(HTTPHOSTHEADER) + strlen(lpwhr->lpszHostName)); + /* if there is optional data to send, add the length */ + if (lpOptional) + { + requestStringLen += dwOptionalLength; + } /* Allocate string to hold entire request */ requestString = HeapAlloc(GetProcessHeap(), 0, requestStringLen + 1); @@ -1304,8 +1318,32 @@ cnt += headerLength; } - /* Set termination string for request */ - strcpy(requestString + cnt, "\r\n\r\n"); + /* Set (header) termination string for request */ + if (memcmp((requestString + cnt) - 4, "\r\n\r\n", 4) != 0) + { /* only add it if the request string doesn't already + have the thing.. (could happen if the custom header + added it */ + strcpy(requestString + cnt, "\r\n"); + cnt += 2; + } + else + requestStringLen -= 2; + + /* if optional data, append it */ + if (lpOptional) + { + memcpy(requestString + cnt, lpOptional, dwOptionalLength); + cnt += dwOptionalLength; + /* we also have to decrease the expected string length by two, + * since we won't be adding on those following \r\n's */ + requestStringLen -= 2; + } + else + { /* if there is no optional data, add on another \r\n just to be safe */ + /* termination for request */ + strcpy(requestString + cnt, "\r\n"); + cnt += 2; + } TRACE("(%s) len(%d)\n", requestString, requestStringLen); /* Send the request and store the results */