WebKItctrl issue

Hi all,

We're having an issue with wxWebKitCtrl ( the one that binds to the WebKit built delivered with OS-X ).

The issue is that when a page gets requested that is mime type text/plain, the file gets displayed in the window.

However, when you click on the same request in Safari, the file gets downloaded instead. What we want in the wx app is for the file to get downloaded.

I've tried to intercept the LoadPage event, but it's not getting triggered.

We can catch the WebKitBeforeLoadEvent, but once there, there doesn't seem to be any way to get the contents of the page, only the url, which makes sense as the page hasn't been loaded yet.

So, is there way to tell webkit how to handle a particular mime type?

Or, is there a way to get it to give me the contents of a page without loading it in a visible Window?

I've tried to just get the page with urllib, but then the sessions don't work -- the server thinks it's a different user accessing the page, so we can't get the right results.

As a side note, ieWin on Windows (embedding IE) just auto-downloads the file, which is the behavior we want.

Any ideas??

-Chris

PS: Robin, this our biggest issue at the moment.

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Hi Chris,

Hi all,

We're having an issue with wxWebKitCtrl ( the one that binds to the WebKit built delivered with OS-X ).

The issue is that when a page gets requested that is mime type text/plain, the file gets displayed in the window.

However, when you click on the same request in Safari, the file gets downloaded instead. What we want in the wx app is for the file to get downloaded.

I've tried to intercept the LoadPage event, but it's not getting triggered.

We can catch the WebKitBeforeLoadEvent, but once there, there doesn't seem to be any way to get the contents of the page, only the url, which makes sense as the page hasn't been loaded yet.

So, is there way to tell webkit how to handle a particular mime type?

Or, is there a way to get it to give me the contents of a page without loading it in a visible Window?

I've tried to just get the page with urllib, but then the sessions don't work -- the server thinks it's a different user accessing the page, so we can't get the right results.

Have you tried changing the user agent string that you send to the server? I'm guessing that's what you need to do to get urllib to work. See the following article for one way to do it:

As a side note, ieWin on Windows (embedding IE) just auto-downloads the file, which is the behavior we want.

Any ideas??

-Chris

PS: Robin, this our biggest issue at the moment.

Hopefully that will solve the urllib issue. If I had a Mac, I might give the other one a go, but I don't.

Mike

Hi Chris,

Hi all,

We're having an issue with wxWebKitCtrl ( the one that binds to the WebKit built delivered with OS-X ).

The issue is that when a page gets requested that is mime type text/plain, the file gets displayed in the window.

However, when you click on the same request in Safari, the file gets downloaded instead. What we want in the wx app is for the file to get downloaded.

I've tried to intercept the LoadPage event, but it's not getting triggered.

We can catch the WebKitBeforeLoadEvent, but once there, there doesn't seem to be any way to get the contents of the page, only the url, which makes sense as the page hasn't been loaded yet.

So, is there way to tell webkit how to handle a particular mime type?

It's probably because we don't have a WebDownloadDelegate to handle content that should be downloaded. Absent that, WebKit probably picks the most reasonable alternative, which in this case would be to just display the content.

To fix this, at the C++ level we'd need to implement a delegate that responds to at least downloadDidFinish and didFailWithError methods and sending equivalent wx events to the client.

Kevin

···

On Dec 5, 2008, at 11:48 AM, Christopher Barker wrote:

Or, is there a way to get it to give me the contents of a page without loading it in a visible Window?

I've tried to just get the page with urllib, but then the sessions don't work -- the server thinks it's a different user accessing the page, so we can't get the right results.

As a side note, ieWin on Windows (embedding IE) just auto-downloads the file, which is the behavior we want.

Any ideas??

-Chris

PS: Robin, this our biggest issue at the moment.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Kevin Ollivier wrote:

The issue is that when a page gets requested that is mime type text/plain, the file gets displayed in the window.

However, when you click on the same request in Safari, the file gets downloaded instead. What we want in the wx app is for the file to get downloaded.

So, is there way to tell webkit how to handle a particular mime type?

It's probably because we don't have a WebDownloadDelegate to handle content that should be downloaded. Absent that, WebKit probably picks the most reasonable alternative, which in this case would be to just display the content.

that makes sense. by the way, we have a similar issue with a text/csv file, and it that case, it does nothing.

To fix this, at the C++ level we'd need to implement a delegate that responds to at least downloadDidFinish and didFailWithError methods and sending equivalent wx events to the client.

OK, but you'd also have to specify a WebDownloadDelegate, presumably -- how would you do that?

Not sure we have time for any of this now, so we'll keep looking for a work-around....

This is custom server, too, so we may be able to change something there.

Or, is there a way to get it to give me the contents of a page without loading it in a visible Window?

I've tried to just get the page with urllib, but then the sessions don't work -- the server thinks it's a different user accessing the page, so we can't get the right results.

As a side note, ieWin on Windows (embedding IE) just auto-downloads the file, which is the behavior we want.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Mike Driscoll wrote:

Or, is there a way to get it to give me the contents of a page without loading it in a visible Window?

I've tried to just get the page with urllib, but then the sessions don't work -- the server thinks it's a different user accessing the page, so we can't get the right results.

Have you tried changing the user agent string that you send to the server? I'm guessing that's what you need to do to get urllib to work. See the following article for one way to do it:

http://wolfprojects.altervista.org/changeua.php

Thanks for this tip, but I don't think that's going to help. The problem is not the user agent, the problem is that the server is managing sessions, and when I send a request from urllib, it isn't the same session as the embedded browser is using, so I get different data from the server.

We're writing the server too, so we may be able to fake a session somehow....

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov