Re: m_HttpResponse does not show image using rdbuf()

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Jeff Dunlap" <JeffDunlap@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A80FCD68-0BCE-4504-B1ED-D561E8E5A736@xxxxxxxxxxxxx
// using rdbuf() does not work for some unknown reason:
m_HttpResponse.WriteStream((LPCSTR)is.rdbuf(), length, NULL);

How on earth do you expect this to work? Why do you believe it's OK to
cast filebuf* to char*?

You are sending contents of some random memory block to the client. You
haven't read a single byte of data from the actual file yet.

If you just want to send contents of a file on disk as is, see
CHttpResponse::TransmitFile.

Alternatively, if I create read the data into a buffer like this it
works:

Well, duh.

Is it possible to display the image using rdbuf()

No.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: m_HttpResponse does not show image using rdbuf()
    ... cast filebuf* to char*? ... // display image via ATL Server ... deletebuffer; ...
    (microsoft.public.vc.atl)
  • Re: Accessing void * buffer/array through char * pointer
    ... What on earth is wrong with the 2? ... I think it is better to say "may invoke undefined behaviour". ... implementations and you, as the programmer, can know (with absolute ... one should always used unsigned char for this purpose since ...
    (comp.lang.c)
  • Re: sprintf function
    ... Earth wrote: ... > I have written a testing program to try the sprintf fuction and expect ... > char* toString ...
    (comp.lang.c)
  • Re: FIRST new bug?!?! =)
    ... > how on earth did you remember to make a 255/256 char long filename? ... > Is that the situation when your program doesn't check if your filename is ... To bad the filer ...
    (comp.sys.hp48)
  • Re: e mail
    ... ocurred in the script on this page.line 1344 char 1.error ... What on EARTH has Office got to do with priniting unavailable in Outlook ...
    (microsoft.public.windowsxp.basics)