• 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

    • all these "selling for great prices" articles feel like filler anymore....
    • It has the same switch to allow whitelisting or not as the regular AdBlock extension.
    • These 20 crypto phishing applications are scamming Play Store users by Hamid Ganji Google Play Store is the main venue for Android users to download applications. While Google has strict rules and policies for verifying apps, some malicious apps somehow slip through anyway. Meanwhile, when it comes to crypto wallet apps, both Google app auditors and Play Store users need to be even more cautious. Cyble Research and Intelligence Labs has identified at least 20 crypto phishing applications on the Google Play Store that impersonate legitimate and popular crypto wallet apps and try to steal users' crypto credentials. By impersonation, these malicious apps trick users into downloading them and then start to capture the user's actual login data. "What makes this campaign particularly dangerous is the use of seemingly legitimate applications, hosted under previously benign or compromised developer accounts, combined with a large-scale phishing infrastructure linked to over 50 domains. This extends the campaign's reach and lowers the likelihood of immediate detection by traditional defenses." Cyble writes. Some of these malicious apps have the same name but come with a different package name. After removing duplicate names, here's the list of 9 newly discovered crypto phishing applications on the Play Store: Pancake Swap Suite Wallet Hyperliquid Raydium BullX Crypto OpenOcean Exchange Meteora Exchange SushiSwap Harvest Finance Blog According to Cyble, these apps prompt users to enter their 12-word mnemonic phrase to access the fake crypto wallet. Also, scammers use accounts that were previously used to distribute legitimate apps to minimize the risk of getting caught by Google. These accounts are more likely to be compromised and then taken over by scammers. If you've downloaded any of these fake crypto wallet apps from the Play Store, make sure to delete them as soon as possible. In 2024, revenue from crypto scams was estimated to be around $9.9 billion. This billion-dollar crypto scam business is expected to grow massively in 2025 thanks to AI.
  • Recent Achievements

    • Reacting Well
      viraltui earned a badge
      Reacting Well
    • Week One Done
      LunaFerret earned a badge
      Week One Done
    • Week One Done
      Ricky Chan earned a badge
      Week One Done
    • Week One Done
      maimutza earned a badge
      Week One Done
    • Week One Done
      abortretryfail earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      482
    2. 2
      +FloatingFatMan
      264
    3. 3
      snowy owl
      239
    4. 4
      ATLien_0
      229
    5. 5
      Edouard
      179
  • Tell a friend

    Love Neowin? Tell a friend!