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:
- <successGreenDot.png>
- Anfrage-Header
- Formulardaten
- Antwort-Header