I found the cause for my trouble. My predecessor had added the following to the 
Application class:

Application:

        public void appendToResponse(WOResponse response, WOContext context) {
                response.disableClientCaching();
                super.appendToResponse(response, context);
                // This must be done after the page generation to override the 
default header created by WO during the page generation.
                if 
(_NSUtilities.UTF8StringEncoding.equals(response.contentEncoding()))
                        response.setHeader("text/html; charset=UTF-8", 
"content-type");
        }

googling "// This must be done after the page generation to ..." revealed that 
adding this hack was popular in 2006. 



Is this hack still necessary today or was the cause for this solved in WO 
meanwhile?


cheers,

        Lars


Am 28.07.2011 um 00:14 schrieb Q:

> Try setting "Content-Length" instead of "Content-length"
> 
> On 28/07/2011, at 4:23 AM, Lars Sonchocky-Helldorf wrote:
> 
>> Hi everybody,
>> 
>> 
>> when trying to deliver a PDF as a special Page using ERXResponse I get 
>> strange results (compared to the state where it was working before 
>> "wonderizing" the WOApp).
>> 
>> The PDF is delivered like this, with data being the PDF data:
>> 
>> public void appendToResponse(WOResponse aResponse, WOContext aContext)
>> {
>>     // Generate PDF bytes
>>     if(data==null) {
>>         data = document.getBytesPDF();
>>     }
>> 
>>     // If not IE, just return the pdf data
>>     aResponse.setHeader("application/pdf", "Content-Type");
>>     aResponse.setHeader("inline; filename=\"" + filename + "\"", 
>> "content-disposition");
>>     aResponse.setHeader("" + data.length, "Content-length");
>>     aResponse.setContent(new NSData(data));
>>    
>> }
>> 
>> 
>> After line 
>> 
>> aResponse.setHeader("" + data.length, "Content-length");
>> 
>> the ERXResponse looks like this:
>> 
>> <er.extensions.appserver.ERXResponse (<er.extensions.appserver.ERXResponse 
>> httpVersion=HTTP/1.1 headers={cache-control=[private, no-cache, no-store, 
>> must-revalidate, max-age=0], content-disposition=[inline; 
>> filename="report.pdf"], content-length=[30873], 
>> content-type=[application/pdf], date=[Wed, 27-Jul-2011 15:54:42 GMT], 
>> expires=[Wed, 27-Jul-2011 15:54:42 GMT], pragma=[no-cache]} content-length=0 
>> cookies=null userInfo={} storePageInBacktrackCache=true >) status=200>
>> 
>> I can imagine only the double entry for content-length here as a possible 
>> problem. Everything else looks fine for me. 
>> 
>> However, the content get's delivered as text/html, e.g. I don't see the PDF, 
>> I see only the ASCII characters that the PDF consists out of in the Safari 
>> Window. Inspecting this using the Web Inspector of WebKit I can see the 
>> following handshake:
>> 
>> Anfrage-URL:http://10.11.3.152:55555/cgi-bin/WebObjects/Portal.woa/wo/yJAzrWNoqCxFt75rZoG5Bw/4.1.7.1.3.1.3
>> Anfragemethode:POST
>> Status-Code:<successGreenDot.png>200 OK
>> Anfrage-Header
>> Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
>> Content-Type:application/x-www-form-urlencoded
>> Origin:http://10.11.3.152:55555
>> Referer:http://10.11.3.152:55555/cgi-bin/WebObjects/Portal.woa/wo/yJAzrWNoqCxFt75rZoG5Bw/3.1.7.1.3.1.3
>> User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-de) 
>> AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
>> Formulardaten
>> 1.7.1.3.1.3.1.1.1.55.1:PDF
>> 1.7.1.3.1.3.1.1.1.69.1.1.3:0
>> Antwort-Header
>> Cache-Control:private, no-cache, no-store, must-revalidate, max-age=0
>> Content-Disposition:inline; filename="report.pdf"
>> Content-Length:30873
>> Content-Type:text/html; charset=UTF-8
>> Date:Wed, 27-Jul-2011 15:54:42 GMT
>> Expires:Wed, 27-Jul-2011 15:54:42 GMT
>> Pragma:no-cache
>> X-Webobjects-Loadaverage:1
>> 
>> 
>> Content-Type is now indeed set to text/html. Does this happen inside WOnder? 
>> How can I stop it?
>> 
>> thanks,
>> 
>>      Lars
>> ------------------------------------------------------------------------------
>> Got Input?   Slashdot Needs You.
>> Take our quick survey online.  Come on, we don't ask for help often.
>> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
>> http://p.sf.net/sfu/slashdot-survey_______________________________________________
>> Wonder-disc mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/wonder-disc
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to