• 0

C web proxy not showing images


Question

I programmed a web proxy in C and the pages seem to load fine. The only problem is images don't load up. I see all the requests for the images and see the data transmitted. When the messages are written to the browser, they don't show up. Anyone have an idea why this would be? What I'm confused on is do images have to be handled differently than the regular html text?

I'm reading everything from the web server(eg Google) into a char buffer of 2048 and write to the browser. This loops until there is nothing more to read. Like I said, the webproxy shows that there is information transferred, but I just get the red x.

Link to comment
https://www.neowin.net/forum/topic/397509-c-web-proxy-not-showing-images/
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Is the proxy sending the HTTP headers correctly?

While browsers usually display HTML pages properly if the headers aren't there, they can't display images if the headers aren't there...

I learnt this while I was creating a small webserver. Browsers only started displaying images when I implented the "sendheaders" function. HTML on the other hand was always displayed properly, even without headers.

  • 0
  anog said:
Is the proxy sending the HTTP headers correctly?

While browsers usually display HTML pages properly if the headers aren't there, they can't display images if the headers aren't there...

I learnt this while I was creating a small webserver. Browsers only started displaying images when I implented the "sendheaders" function. HTML on the other hand was always displayed properly, even without headers.

586806184[/snapback]

So I need to forward the entire request, including headers? I figured that just the GET request with the file and protocol was enough. I didn't think that I needed to include the entire header. Let me give this a try. Thanks for the explaination.

  • 0

Still no luck getting the image to load. I just don't see how I can transfer the image data correctly with a character buffer. Does anyone have an idea how I can handle this data correctly? The information that is being passed to the browser is the same information when you open an image in notepad, garbled text and symbols. Any suggestions?

  • 0
  minhaferzz said:
Still no luck getting the image to load.  I just don't see how I can transfer the image data correctly with a character buffer.  Does anyone have an idea how I can handle this data correctly?  The information that is being passed to the browser is the same information when you open an image in notepad, garbled text and symbols.  Any suggestions?

586809572[/snapback]

Be careful with your buffer, because it contains binary data if you use it for transferring images. Thus a string function like strlen() for example will likely not work --at least not all the time. You may want to consider an array of bytes instead.

The easy way to resolve your problem is to sniff on the network traffic with and without your proxy and then compare the results for the same requests, then you should be able to tell what is different when the proxy is enabled and it should be trivial to fix.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • "vista rebranded" lol w7 works, its not slow and sluggish we cant say the same thing about vista that run like crap even on new machines.
    • just get iot enterprise ltsc 2021 thats the w10 with support until 2032
    • Rufus 4.9.2256 by Razvan Serea Rufus is a small utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc. Despite its small size, Rufus provides everything you need! Oh, and Rufus is fast. For instance it's about twice as fast as UNetbootin, Universal USB Installer or Windows 7 USB download tool, on the creation of a Windows 7 USB installation drive from an ISO (with honorable mention to WiNToBootic for managing to keep up). It is also marginally faster on the creation of Linux bootable USBs from ISOs. A non-exhaustive list of Rufus supported ISOs is available here. It can be especially useful for cases where: you need to create USB installation media from bootable ISOs (Windows, Linux, UEFI, etc.) you need to work on a system that doesn't have an OS installed you need to flash a BIOS or other firmware from DOS you want to run a low-level utility Rufus 4.8.2253 changelog: Switch to wimlib for all WIM image processing: Greatly speeds up image analysis when opening Windows ISOs Can speed up Windows To Go drive creation (But won't do miracles if you have a crap drive) Might help with Parallels limitations on Mac (But Rufus on Parallels is still unsupported) Enables the splitting of >4GB files with Alt-E (But still WAY SLOWER than using UEFI:NTFS) Others Switch to using Visual Studio binaries everywhere, due to MinGW DLL delay-loading limitations Add more exceptions for Linux ISOs that restrict themselves to DD mode (Nobara, openSUSE, ...) Improve reporting of UEFI bootloaders in the log, with info on the Secure Boot status Fix an issue with size limitations when writing an uncompressed VHD back to the same drive Fix a crash when opening the log with the 32-bit MinGW compiled version Fix commandline parameters not being forwarded to original Windows setup.exe Rufus 4.9.2256 fixes: Fix downloads from https://rufus.ie no longer working due to recent GitHub server changes Fix unofficial Windows ISOs, with single index WIMs, not presenting the WUE dialog Download: Rufus 4.9 | Portable | ~2.0 MB (Open Source) Download: Rufus 32-bit | ARM64 Links: Rufus Home Page | Project Page @GitHub | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • CrystalDiskInfo 9.7.0 by Razvan Serea CrystalDiskInfo is a HDD/SSD health monitoring utility. It displays basic HDD (also SSD and USB-HDD) information, monitors S.M.A.R.T. values and disk temperature. It will also display the S.M.A.R.T data as a list so you can see the specific issue that a hard drive may have. It provides a health rating based on your drive’s SMART status, plus will list its temperature, enabling you to see just how hot your drives are running. As various factors approach thresholds of danger, CrystalDiskInfo will alert you, letting you know it's time to make backups while you still can. CrystalDiskInfo 9.7.0 changelog: Added “CrystalMark Inc.” as copyright holder Changed code signature to “CrystalMark Inc.” Updated Core Library (Project Priscilla) Added AoiLight~TenmuShinryuusai / AoiLightAnimalEars~TenmuShinryuusai / AoiDark~TenmuShinryuusai / AoiDarkAnimalEars~TenmuShinryuusai theme [Aoi Edition] Added ShizukuLight~TenmuShinryuusai / ShizukuLightAnimalEars~TenmuShinryuusai / ShizukuDark~TenmuShinryuusai / ShizukuDarkAnimalEars~TenmuShinryuusai theme [Shizuku Edition] Updated language file (Portuguese, PortugueseRT) Download: CrystalDiskInfo 9.7.0 | 5.7 MB (Open Source) Download: Portable CrystalDiskInfo 9.7.0 | 7.8 MB View: CrystalDiskInfo Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Never use an in-browser password manager. It creates a barrier to using any other web browser.
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      622
    2. 2
      ATLien_0
      277
    3. 3
      +FloatingFatMan
      178
    4. 4
      Michael Scrip
      151
    5. 5
      Steven P.
      115
  • Tell a friend

    Love Neowin? Tell a friend!