Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CHttpFile Read Problem

CHttpFile Read Problem

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmindebugginghelpannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aman2006
    wrote on last edited by
    #1

    Hi When i read the returned data from the server in data chunks of 2048 size it is appending the server URL with each chunk read.I have the code like: m_strResponseData.Empty(); do { memset(szBuf,0x00,sizeof(szBuf)); nBytesRead = pHttpFile->Read((void*) szBuf, CHUNK_SIZE); m_strResponseData += szBuf; if(nBytesRead < CHUNK_SIZE) break; }while(nBytesRead == CHUNK_SIZE); But when i run this program in debug mode it is not appending any URL in the data returned but in release mode it is appending the server URL in each chunk read. I don't want server URL with every chunk size read. Can any body tell me how is it appending the server URL with the data I read from the server. Thanks Shailesh

    M 1 Reply Last reply
    0
    • A aman2006

      Hi When i read the returned data from the server in data chunks of 2048 size it is appending the server URL with each chunk read.I have the code like: m_strResponseData.Empty(); do { memset(szBuf,0x00,sizeof(szBuf)); nBytesRead = pHttpFile->Read((void*) szBuf, CHUNK_SIZE); m_strResponseData += szBuf; if(nBytesRead < CHUNK_SIZE) break; }while(nBytesRead == CHUNK_SIZE); But when i run this program in debug mode it is not appending any URL in the data returned but in release mode it is appending the server URL in each chunk read. I don't want server URL with every chunk size read. Can any body tell me how is it appending the server URL with the data I read from the server. Thanks Shailesh

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      aman2006 wrote: m_strResponseData += szBuf; That's the problem. szBuf is usually not going to be zero-terminated, but you're treating it like it is. You're seeing the server URL in there because that just happens to be in memory right after the buffer. Change it to:

      m_strResponseData += CString ( (LPCSTR) szBuf, nBytesRead );

      --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- #include "witty-quote.h"

      A 1 Reply Last reply
      0
      • M Michael Dunn

        aman2006 wrote: m_strResponseData += szBuf; That's the problem. szBuf is usually not going to be zero-terminated, but you're treating it like it is. You're seeing the server URL in there because that just happens to be in memory right after the buffer. Change it to:

        m_strResponseData += CString ( (LPCSTR) szBuf, nBytesRead );

        --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- #include "witty-quote.h"

        A Offline
        A Offline
        aman2006
        wrote on last edited by
        #3

        Thanks Mike u r rock, but i want to ask u why it is giving the right data without http in debug mode. thanks shailesh

        M 1 Reply Last reply
        0
        • A aman2006

          Thanks Mike u r rock, but i want to ask u why it is giving the right data without http in debug mode. thanks shailesh

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Dumb luck. The layout of things in memory is much different in debug mode, due to the CRT's debug checks to catch buffer under/overrun errors. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Actual sign at the laundromat I go to: "No tinting or dying."

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups