Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441698
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:35:05+00:00 2026-05-18T08:35:05+00:00

I have an internal proxy that fetches data from my own server and displays

  • 0

I have an internal proxy that fetches data from my own server and displays to the client. I wanted to keep the proxy side code minimal, and thought that just sending the data got from the content server as-it-is to the client will work for all media types. It is working fine for HTML/TEXT code. However, not for images. I am unable to understand why.

Here is the proxy side code:

$curl_url="http//myserver.com/someimage.jpg";
//Open connection
$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_COOKIE,session_name()."=".session_id().";");
//Set the url, number of POST vars, POST data
curl_setopt($curl_handle, CURLOPT_URL, $curl_url);
curl_setopt($curl_handle, CURLOPT_POST, count($_POST));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
/// curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $curl_request_headers);
/// Above is actually uncommented but omitting details for brevity. They are just 
/// HTTP headers passed by the client
curl_setopt($curl_handle, CURLOPT_ENCODING, "identity");

//Execute post
$result = curl_exec($curl_handle);

//Close connection
curl_close($curl_handle);

echo $result;

Why does above not display images correctly? (Is it not possible to make the proxy like a dummy bridge – that it does not interpret the result sent by the server but just pass it on and still make it work for all content/media types?). Can someone suggest the cleanest solution?


Notes:

1) The content server handles all files through a php script, and is correctly passing the header using
header('Content-Type: image/jpeg');

It works fine if I access directly from the server. However from the proxy, it does not work (browser displays binary data).

2)
I don’t understand CURLOPT_HEADER very well either.

If I use

curl_setopt($curl_handle, CURLOPT_HEADER, 1);

browser tries to download gzipped data (for text as well as images).

If I use

curl_setopt($curl_handle, CURLOPT_HEADER, 0);

browser displays text/images correctly, but not image data.


These are the response headers shown by Google Chrome, when I access the image in the browser via the proxy (direct link).

Response Headers
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:2576
Content-Type:text/html
Date:Mon, 29 Nov 2010 18:03:52 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=100
Pragma:no-cache
Server:Apache/2.2.14 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.2-1ubuntu4.5

The response headers when I access image directly on the content server:

Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:3669
Content-Type:image/jpeg
Date:Mon, 29 Nov 2010 18:07:25 GMT
ETag:"1802b6-e55-49633c9623e40"
Keep-Alive:timeout=15, max=96
Last-Modified:Mon, 29 Nov 2010 16:44:33 GMT
Server:Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.6 with Suhosin-Patch mod_ssl/2.2.11 OpenSSL/0.9.8g

I have a feeling this is due to the Content-type being GZIP via the proxy. Can someone please help me understand this: Aren’t images GZIPPed by apache by default? (I agree savings might be less). If not, then is CURL (the proxy) Gzipping the data? Shouldn’t CURLOPT_ENCODING, “identity” prevent it? How do I fix?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:35:06+00:00Added an answer on May 18, 2026 at 8:35 am

    You need to send the proper headers using header to tell the browser the correct content-type, otherwise it assumes it is just plaintext.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a internal website that users log into. This data is saved as
I have an internal customer that only receives his email report from MS Report
We have an internal .NET case management application that automatically creates a new case
I have an internal enterprise app that currently consumes 10 different web services. They're
This a bit of strange one.... We have an internal web app that runs
Why can NHibernate create a proxy for classes with properties that have private setters
A have setup an internal proxy kind of thing using Curl and PHP. The
I'm using Castle Windsor for SL v2.5.1.0. I have it proxy internal classes (the
I have an internal web app with an image at the top of the
I have an internal enterprise application I've developed for my company built on .Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.