ISAPI image
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ISAPI image

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    3

    ISAPI image

    Hello, I am a newbee on WinCE and on ISAPI. I have managed to create an ISAPI dll that dynamically generated html pages and sends them to the client.

    When I put an <img> tag in my html, I notice that an additional call to HttpExtensionProc is made with the image (file)name in the lpszPathInfo member of the EXTENSION_CONTROL_BLOCK struct.

    My problem is, that I can't find out how to send the image data. My attempts until now fail.

    An excerpt of my code (taken from my HttpExtensionProc implementation):

    HANDLE hFile;
    BYTE byBuffer[512];
    DWORD dwBytesRead;
    HSE_SEND_HEADER_EX_INFO HeaderExInfo;
    char chHeader[100];

    hFile = CreateFile(szFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    dwBytesRead = GetFileSize(hFile, NULL);
    sprintf_s(chHeader, 100, "Content-Type: image/jpeg\r\nContent-length: %d\r\n", dwBytesRead);
    HeaderExInfo.pszStatus = "200 OK";
    HeaderExInfo.pszHeader = chHeader;
    HeaderExInfo.cchStatus = strlen(HeaderExInfo.pszStatus);
    HeaderExInfo.cchHeader = strlen(HeaderExInfo.pszHeader);
    HeaderExInfo.fKeepConn = FALSE;
    pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &HeaderExInfo, NULL, NULL));
    ReadFile(hFile, byBuffer, 512, &dwBytesRead, NULL);
    while (dwBytesRead > 0) {

    g_WriteClient(pECB->ConnID, byBuffer, &dwBytesRead, 0));
    ReadFile(hFile, byBuffer, 512, &dwBytesRead, NULL);

    }
    CloseHandle(hFile);


    Any hints?

  2. #2
    Join Date
    Oct 2011
    Posts
    3

    Re: ISAPI image

    Note, the error I get after the line:
    Code:
     
    g_WriteClient(pECB->ConnID, byBuffer, &dwBytesRead, 0));
    is 10054 - WSACONNRESET - An existing connection was forcibly closed by the remote host.

    Now, I just read on http://www.west-wind.com/weblog/post...lient-oddities that:
    However, under IIS5 this value [in my code, the dwBytesRead variable. RV] does not always return the bytes written. It returns 0 and an error code of 10054 - even though the data gets written out to the Response stream just fine. I also remember in the past that I was told (I think by Wade Hilmo) that the result value from WriteClient() is unreliable and can indicate failure when the call actually worked - this was a big thing in IIS 4 and caused me to ignore any errors which hasn't been a problem.
    This might be unrelated to WinCE though. But the similar error code triggers me.
    In the end, my browser still does not display an image...

    BTW - sorry for the ommision of CODE tags in my initial message.

  3. #3
    Join Date
    Oct 2011
    Posts
    3

    Re: ISAPI image

    Problem solved!

    Instead of:
    Code:
    sprintf_s(chHeader, 100, "Content-Type: image/jpeg\r\nContent-length: %d\r\n", dwBytesRead);
    It needed:
    Code:
    sprintf_s(chHeader, 100, "Content-Type: image/jpeg\r\nContent-length: %d\r\n\r\n", dwBytesRead);
    (Thus with an extra \r\n)

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center