Re: csv report download -> Safari adding .html to filename?
Re: csv report download -> Safari adding .html to filename?
- Subject: Re: csv report download -> Safari adding .html to filename?
- From: Leif Harrison <email@hidden>
- Date: Thu, 09 Apr 2009 22:45:57 -0700
Well, that appears to have worked! Thank you Chuck!
- Leif
On Apr 9, 2009, at 9:36 PM, Chuck Hill wrote:
On Apr 9, 2009, at 6:33 PM, Leif Harrison wrote:
Okay, now I might be getting somewhere.
Here's the output from curl to the component action (once I figured
out how to do it...):
...
< content-type: text/html; charset=iso-8859-1
...
So...the headers ARE different...but I have idea why WO is changing
my Content-Type after I have explicitly set it...?
OK, I think I maybe see what is going wrong. Try this change:
public WOComponent downloadReport() {
if (reportFilename == null) {
return this;
}
MWCSVReport report = this.pageWithName(MWCSVReport.class);
report.setReportStartDate(reportStartDate);
report.setReportEndDate(reportEndDate);
report.setReportFilename(reportFilename);
report.setReportFields(selectedDefinitions);
return report;
Instead of returning report, return the response:
return report.generateResponse();
}
You are setting the content type too early.
Chuck
On Apr 9, 2009, at 5:35 PM, Chuck Hill wrote:
curl the two and check for differences in the headers
On Apr 9, 2009, at 5:25 PM, Leif Harrison wrote:
Okay, so here's an interesting thing...I created a direct action
that returns a pre-configured (to hard-code some login
information and such) version of the response page so that I
could test using curl. I noticed that...if I use that same
direct action URL in Safari...I magically get the correct
results, without the .html.
So...does anyone know why Safari would be treating the direct-
action results different than the results from a component action?
- Leif
On Apr 9, 2009, at 3:10 PM, Leif Harrison wrote:
On Apr 9, 2009, at 12:54 PM, email@hidden wrote:
This should be straightforward and with the exception of (1)
below, I don't see any errors. Here's a couple of things to try:
1) you shouldn't be calling super.appendToResponse()
Okay, got rid of that, but still no luck.
2) does reportFilename end in ".csv"?
It does, yes.
3) safari's activity window shows no errors, right?
No errors in the activity window.
4) use curl or tcpdump to look at the response and headers
Here's the output from curl:
Ocelot[15]: curl --verbose 'http://localhost:4700/cgi-bin/WebObjects/MWService.woa/wa/downloadReport'
* About to connect() to localhost port 4700 (#0)
* Trying ::1... Connection refused
* Trying fe80::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 4700 (#0)
> GET /cgi-bin/WebObjects/MWService.woa/wa/downloadReport HTTP/1.1
> User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/
7.16.3 OpenSSL/0.9.7l zlib/1.2.3
> Host: localhost:4700
> Accept: */*
>
< HTTP/1.1 200 Apple WebObjects
< cache-control: private
< cache-control: no-cache
< cache-control: no-store
< cache-control: must-revalidate
< cache-control: max-age=0
< content-disposition: attachment; filename=test.csv
< expires: Thu, 09-Apr-2009 21:48:30 GMT
< content-type: text/csv
< pragma: no-cache
< x-webobjects-loadaverage: 5
< date: Thu, 09-Apr-2009 21:48:30 GMT
< content-length: 386
<
Activity Name,Schedule Start,Schedule End
New Activity,2009-04-09 14:32:51-0700,null
New Activity,2009-04-09 14:32:51-0700,null
New Activity,2009-04-09 14:32:52-0700,null
New Activity,2009-04-09 14:32:52-0700,null
New Activity,2009-04-09 14:32:55-0700,null
New Activity,2009-04-09 14:32:56-0700,null
New Activity,2009-04-09 14:32:57-0700,null
New Activity,2009-04-09 14:32:57-0700,null
* Connection #0 to host localhost left intact
* Closing connection #0
Ocelot[16]:
5) make sure your headers are correct and your content really
is UTF8
Would there be a better encoding to use for simple csv text
output?
- Leif
_______________________________________________
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
_______________________________________________
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
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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