Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I expect a response from the server after sending it some data with HttpSendRequest() function. I want to read the response, I call the HttpQueryInfo() function, and the debugger stops with Exception thrown ... Access violation reading location 0x00000800 message. I'd use the buffer array for the response, and I assume the problem is somewhere there. I don't get any errors with the GetLastError() function.
else if (method == _T("POST")) {
		LPCTSTR header = _T("Content-Type: text/html\nCustomers");
		BOOL hHttpSendReq = HttpSendRequest(hHttpOpenReq, NULL, NULL, toSend, strlen(toSend));
		if (!hHttpSendReq) {
			DWORD ErrorNum = GetLastError();
			std::cout << "HttpSendRequest() error No: " << ErrorNum;
			InternetCloseHandle(hHttpOpenReq);
			InternetCloseHandle(hIntConnect);
			InternetCloseHandle(hIntOpen);
			getchar();
			return 0;
		}
		char buffer[2048];
		if (HttpQueryInfo(hHttpOpenReq, HTTP_QUERY_RAW_HEADERS_CRLF, buffer, (LPDWORD)2048, NULL)) {
		
		}
		else {
			cout << "GetLastError:"<<GetLastError();
		}

In the debugger 'buffer' is shown red, and there is no content in there, only funny characters.
Any idea? Thanks.

What I have tried:

I don't know where to look, I checked some examples on the net, but they look similar. I also changed the flags (arguments), but I don't think the problem is there anyway.
Posted
Updated 11-Mar-18 23:31pm
v2

1 solution

I don't know exactly what the problem was, but now it works :)
char buffer[4096];
		DWORD bufferSize = 4096;
		if (HttpQueryInfo(hHttpOpenReq, HTTP_QUERY_RAW_HEADERS_CRLF, (LPVOID)buffer, &bufferSize, NULL)) {
			cout << "buffer:" << buffer;
		}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900