2

I am making a simple POST request using WinInet to an apache web server. I encode the data using base 64. The problem is that, every + character gets replaced by space character.

Why is that and how can I make correct POST request.

hInternet = InternetOpen(NULL, INTERNETOPENTYPEPRECONFIG, NULL, NULL, 0);
if (hInternet)
{
    hConnect = InternetConnect(hInternet, szDomain, INTERNETDEFAULTHTTPPORT, NULL, NULL, INTERNETSERVICEHTTP, 0, dwTmp);
    if (hConnect)
    {
        hRequest = HttpOpenRequest(hConnect, szPost, szExfiltrationURL, NULL, NULL,(char *)accept, INTERNETFLAGNOCACHEWRITE | INTERNETFLAGNOCOOKIES | INTERNETFLAGNOUI | INTERNETFLAGRELOAD, 0);
        if (hRequest)
        {
            HttpSendRequest(hRequest, headers, lstrlen(headers), buffer, buflen);
            InternetCloseHandle(hRequest);
        }

        InternetCloseHandle(hConnect);
    }

    InternetCloseHandle(hInternet);
}
1
  • Why are you encoding data as base64 in the first place? A POST body can contain unencoded binary data. And in a POST request, your data should be in the body and not in the URL. Commented Aug 1, 2014 at 15:45

1 Answer 1

4

From W3

"Within the query string, the plus sign is reserved as shorthand notation for a space:

Source: "http://www.w3.org/Addressing/URL/4_URI_Recommentations.html"

Sign up to request clarification or add additional context in comments.

1 Comment

You can use percent encoding. w3schools.com/tags/ref_urlencode.asp So '+' becomes %2B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.