• 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

    • It's a 3v3 fighting system which Mortal Kombat has never done, unless you are talking about the hitstop animation and so on
    • Apple's future is glass-centric, and the new glassy UI is just the beginning  by Hamid Ganji Apple will unveil its overhauled UI experience at today’s WWDC event. The new UI will be available on all Apple devices, including iPhones, iPads, and Mac devices, and it will take most of its cues from visionOS. Bloomberg’s Mark Gurman has now provided us with new details about Apple’s new UI. The new interface is called Liquid Glass and has “sheen and see-through visuals of a glassy surface.” The name represents Apple’s approach to designing the new interface. The new UI also brings “transparency and shine effects in all of Apple’s tool bars, in-app interfaces and controls.” However, Gurman notes that the Liquid Glass interface will lay the groundwork for Apple’s future products, especially the 20th anniversary iPhone. It was already reported that Apple plans to unveil at least two new devices in 2027, which coincides with the iPhone’s 20th anniversary. The first model would be the long-awaited foldable iPhone. However, the second model, the 20th anniversary iPhone, is a glass-centric model that aligns with Apple’s new UI concept. According to Gurman, the 20th anniversary iPhone has curved glass sides and edges. It also features “extraordinarily slim bezels” and “no cutout section in the screen.” The phone is reportedly called “Glasswing,” which refers to the type of butterfly with transparent wings. Apple’s upcoming iOS 26 is the biggest overhaul to iPhone UI since the launch of iOS 7 in 2013. The new UI also hits iPadOS 26, tvOS 26, visionOS 26, watchOS 26, macOS 26. As a side note, the new “26” on the name of Apple’s operating system represents the year 2026.
    • Listen, adrynalyne - You're trolling me (I've known this for months). If you have something meaningful to say - say it, don't ask as if you know something, becauser you know sh*t. Ok?
  • Recent Achievements

    • Week One Done
      Al_ earned a badge
      Week One Done
    • Week One Done
      MadMung0 earned a badge
      Week One Done
    • Reacting Well
      BlakeBringer earned a badge
      Reacting Well
    • Reacting Well
      Lazy_Placeholder earned a badge
      Reacting Well
    • Dedicated
      Epaminombas earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      475
    2. 2
      +FloatingFatMan
      273
    3. 3
      ATLien_0
      242
    4. 4
      snowy owl
      211
    5. 5
      Edouard
      182
  • Tell a friend

    Love Neowin? Tell a friend!