Bug 109776 - CMS Image dispatcher doesn't set content type
CMS Image dispatcher doesn't set content type
Status: CLOSED RAWHIDE
Product: Red Hat Enterprise CMS
Classification: Retired
Component: other (Show other bugs)
nightly
All Linux
medium Severity medium
: ---
: ---
Assigned To: Vadim Nasardinov
Jon Orris
:
Depends On:
Blocks: 109665
  Show dependency treegraph
 
Reported: 2003-11-11 13:22 EST by Daniel Berrange
Modified: 2007-04-18 12:59 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-12-04 11:41:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2003-11-11 13:22:17 EST
Description of problem:
The CMS image dispatcher (c.a.cms.disaptcher.StreamImage) does not set
the response content type header. So, if you point a browser directly
at, for example,
http://camden.aplaws.org.uk/cms-service/stream/image/?image_id=135565
it displays the RAW binary data as text, rather than interpreting it
as an image.

Version-Release number of selected component (if applicable):


How reproducible:
So far only with Galeon 1.2. Internet Explorer auto-magically guesses
a contnet type & displays the image.

Steps to Reproduce:
1. Point the browser at an image url in cms-service/stream/image
2.
3.
  
Actual results:
Raw binary data displayed as text


Expected results:
Image displayed

Additional info:

Patch from my checkout

==== //cms/dev/src/com/arsdigita/cms/dispatcher/StreamImage.java#13 -
/var/ccm-devel/dev/dan/aplaws-rickshaw/cms/src/com/arsdigita/cms/dispatcher/StreamImage.java
====
--- /tmp/tmp.14414.1    Tue Nov 11 18:24:17 2003
+++
/var/ccm-devel/dev/dan/aplaws-rickshaw/cms/src/com/arsdigita/cms/dispatcher/StreamImage.java
       Tue Nov 11 18:07:27 2003
@@ -28,6 +28,7 @@
 import com.arsdigita.persistence.DataQuery;
 import com.arsdigita.persistence.SessionManager;
 import com.arsdigita.versioning.Transaction;
+import com.arsdigita.mimetypes.MimeType;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
@@ -161,6 +162,8 @@
         // Not until permissions are properly assigned to assets
         //checkUserAccess(request, response, actx, image);
 
+        MimeType type = image.getMimeType();
+        response.setContentType(type.getMimeType());
         // Stream the blob.
         OutputStream out = response.getOutputStream();
        image.writeBytes(out);
Comment 1 Daniel Berrange 2003-11-12 13:12:08 EST
Incidentlly, it should probably be backported to 6.0 & possibly 5.2 as
well.
Comment 2 Vadim Nasardinov 2003-11-12 19:28:56 EST
Fixed on the trunk (modulo bug 109920) at change 37940.

Before the fix:

|$ wget --server-response http://el-vadimo.home:9002/ccm/cms-service/stream/image/?image_id=6007
|--19:12:02--  http://el-vadimo.home:9002/ccm/cms-service/stream/image/?image_id=6007
|           => `index.html?image_id=6007.1'
|Resolving el-vadimo.home... done.
|Connecting to el-vadimo.home[127.0.0.1]:9002... connected.
|HTTP request sent, awaiting response... 
| 1 HTTP/1.0 200 OK
| 2 Server: Resin/2.1.4
| 3 Cache-Control: public, max-age=259200
| 4 Expires: Sun, 16 Nov 2003 00:12:02 GMT
| 5 Last-Modified: Thu, 13 Nov 2003 00:12:02 GMT
| 6 Set-Cookie: JSESSIONID=aiU67Hjw63s9; Path=/
| 7 Date: Thu, 13 Nov 2003 00:12:02 GMT
|
|    [ <=>                                 ] 76,504         2.92M/s             
|
|19:12:02 (2.92 MB/s) - `index.html?image_id=6007.1' saved [76504]


After the fix:

|$ wget --server-response http://el-vadimo.home:9002/ccm/cms-service/stream/image/?image_id=6007
|--19:21:40--  http://el-vadimo.home:9002/ccm/cms-service/stream/image/?image_id=6007
|           => `index.html?image_id=6007.2'
|Resolving el-vadimo.home... done.
|Connecting to el-vadimo.home[127.0.0.1]:9002... connected.
|HTTP request sent, awaiting response... 
| 1 HTTP/1.0 200 OK
| 2 Server: Resin/2.1.4
| 3 Cache-Control: public, max-age=259200
| 4 Expires: Sun, 16 Nov 2003 00:21:50 GMT
| 5 Last-Modified: Thu, 13 Nov 2003 00:21:50 GMT
| 6 Set-Cookie: JSESSIONID=aqQGCcYQGYW5; Path=/
| 7 Content-Type: image/jpeg
| 8 Date: Thu, 13 Nov 2003 00:21:50 GMT
|
|    [ <=>                                 ] 76,504         5.21M/s             
|
|19:21:50 (5.21 MB/s) - `index.html?image_id=6007.2' saved [76504]
Comment 3 Vadim Nasardinov 2003-11-13 16:33:03 EST
Integrated onto the cms-6.0 branch in change 37985.

Integrated onto the cms-5.2 branch in change 37986.

Note You need to log in before you can comment on or make changes to this bug.