Bug 109776 - CMS Image dispatcher doesn't set content type
Summary: CMS Image dispatcher doesn't set content type
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Enterprise CMS
Classification: Retired
Component: other
Version: nightly
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Vadim Nasardinov
QA Contact: Jon Orris
URL:
Whiteboard:
Depends On:
Blocks: 109665
TreeView+ depends on / blocked
 
Reported: 2003-11-11 18:22 UTC by Daniel Berrangé
Modified: 2007-04-18 16:59 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-12-04 16:41:52 UTC
Embargoed:


Attachments (Terms of Use)

Description Daniel Berrangé 2003-11-11 18:22:17 UTC
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 Berrangé 2003-11-12 18:12:08 UTC
Incidentlly, it should probably be backported to 6.0 & possibly 5.2 as
well.

Comment 2 Vadim Nasardinov 2003-11-13 00:28:56 UTC
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 21:33:03 UTC
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.