본문 바로가기

Development

[HTTP] ERROR_HTTP_HEADER_NOT_FOUND 에러 발생시 원인 및 해결법

if ( !HttpSendRequest(m_hRequest, _T("Content-Type: application/x-www-form-urlencoded"), (DWORD)-1L, (LPVOID)strPostBlock.c_str(), nPostBlock) )
{ ... }
이런 코드를 배껴와서 이용해보니 IE6.0인 PC에서는 에러가 발생했다.

GetLastError()로 확인해 보니 12150 Error였다.
ERROR_HTTP_HEADER_NOT_FOUND (12150 - The requested header could not be located.)

이것의 원인을 몰라 여기저기 찾아 봤더니 아래와 같은 내용이 있었다.

살짝만 읽어 보면 누구나 눈치첸다. content-length 그래서 아래처럼 바꿨더니 모든 PC환경에서 잘 돌아갔다.
tstring tstrHeader = _T("Content-Type: application/x-www-form-urlencoded");
if ( !HttpSendRequest(m_hRequest, tstrHeader.c_str(), (DWORD)tstrHeader.length(), (LPVOID)strPostBlock.c_str(), nPostBlock) )
{ ... }