CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Galway, Ireland
    Posts
    96

    CHttpFile QueryInfoStatusCode 406 error

    I have recently moved my websites from a linux machine to a windows .net v2 machine. I've been having various teething pains due to the differences and the latest affects the autoupgrade feature of a freeware program. The program checks this URL:
    http://lava.lounge111.net/gong/gong!version.dat

    Assuming its not in the internet cache (aka if I browse to it the code will work) the code gets a 406 HTTP_STATUS_NONE_ACCEPTABLE.

    Interestingly, although this doesn't help the current installs looking at the above URL, if I change the software to look at this URL:
    http://lava.lounge111.net/gong/gong!version.txt
    it works perfectly. So there is some play between the extension txt vs. dat. Initially the server wouldn't serve up a dat file at all, it returned a 404. I contacted the ISP and, without explaining what they've done, I can now browse to it. But via the code no such luck, I get a 406.

    Code:
        CHttpConnection* pServer = NULL;
        CHttpFile* pFile = NULL;
            pServer = session.GetHttpConnection(strServerName, nPort);
            
            pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
                strObject, NULL, 1, NULL, NULL, INTERNET_FLAG_EXISTING_CONNECT);
            const TCHAR szHeaders[] =
                _T("Accept: text/*\r\nUser-Agent: GONG_Update\r\n");
            pFile->AddRequestHeaders(szHeaders);
            pFile->SendRequest();
            
            DWORD dwRet;
            pFile->QueryInfoStatusCode(dwRet);
    I was wondering if it was the headers. Does anyone have any ideas?

  2. #2
    Join Date
    Apr 1999
    Location
    Galway, Ireland
    Posts
    96

    Re: CHttpFile QueryInfoStatusCode 406 error

    By commenting out AddRequestHeaders the dat file did download. The 406 indicated a header problem alright. However this doesn't help current installs so they will never upgrade themselves to pick up the change.

    In the end either its IIS or the ISP's configuration which is handling a dat file differently from linux. However, I don't understand exactly what the difference is.
    Last edited by Chris Green; March 28th, 2006 at 05:32 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured