• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Wonder-disc] delivering a PDF using ERXResponse: Content-type question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Wonder-disc] delivering a PDF using ERXResponse: Content-type question


  • Subject: Re: [Wonder-disc] delivering a PDF using ERXResponse: Content-type question
  • From: Lars Sonchocky-Helldorf <email@hidden>
  • Date: Thu, 28 Jul 2011 19:22:00 +0200

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:

  1. Anfrage-URL:
    http://10.11.3.152:55555/cgi-bin/WebObjects/Portal.woa/wo/yJAzrWNoqCxFt75rZoG5Bw/4.1.7.1.3.1.3
  2. Anfragemethode:
    POST
  3. Status-Code:
    <successGreenDot.png>
    200 OK
  4. Anfrage-Header
    1. Accept:
      application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    2. Content-Type:
      application/x-www-form-urlencoded
    3. Origin:
      http://10.11.3.152:55555
    4. Referer:
      http://10.11.3.152:55555/cgi-bin/WebObjects/Portal.woa/wo/yJAzrWNoqCxFt75rZoG5Bw/3.1.7.1.3.1.3
    5. 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
  5. Formulardaten
    1. 1.7.1.3.1.3.1.1.1.55.1:
      PDF
    2. 1.7.1.3.1.3.1.1.1.69.1.1.3:
      0
  6. Antwort-Header
    1. Cache-Control:
      private, no-cache, no-store, must-revalidate, max-age=0
    2. Content-Disposition:
      inline; filename="report.pdf"
    3. Content-Length:
      30873
    4. Content-Type:
      text/html; charset=UTF-8
    5. Date:
      Wed, 27-Jul-2011 15:54:42 GMT
    6. Expires:
      Wed, 27-Jul-2011 15:54:42 GMT
    7. Pragma:
      no-cache
    8. 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@hidden
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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Dynamic loading of a component into a container?
  • Next by Date: Re: Dynamic loading of a component into a container?
  • Previous by thread: Re: Dynamic loading of a component into a container?
  • Next by thread: eclipse lockup on saving .html
  • Index(es):
    • Date
    • Thread