Bug 18676

Summary: Plug-In API Proposal: Enable plugins to receive response body when an HTTP error occurs
Product: WebKit Reporter: Dimcho Balev <dbalev>
Component: Plug-insAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: andersca, ap, marc.ordinasillopis
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Description Flags
First crude patch (mac only)
Updated the patch with new constant name and value
Fixed a bug about missing http status line. Added Windows/Linux code andersca: review+

Description Dimcho Balev 2008-04-22 00:33:06 PDT
Many flash developers have continuously asked Adobe for several HTTP related changes in the flash player. They really need:

1. Access to the HTTP status code
2. Access to the HTTP response headers
3. Access to the HTTP body even when the http request is unsuccessful

Response headers and status codes (1 & 2) are already available (in up-to-date browsers) via the NPStream struct passed to NPP_NewStream.

The only missing part is the HTTP bodies (3) on failed http requests.

I have filed similar bug for Firefox:


The difference between FireFox and Safari is that on http error Safari still sends NPN_NewStream to the plugin and it is possible to retrieve the http status code. As with Firefox, Safari does not send NPP_Write and thus prevents the plugin of receiving the http body.

Here is the proposal that should solve this issue while remaining compatible with older code:

In the cases of http errors the browser should asks the plugin if it is interested in receiving the body of failed request - it should  call NPP_GetValue with new enum called NPPVpluginWantsHTTPFailStreams = 17. If the plugin does not understand what the browser is asking or if the plugin is not interested everything will work as before. In the other case the browser should send NPP_NewStream, NPP_WriteReady, NPP_Write, and NPP_DestroyStream as it does for urls that return 200 OK.
Comment 1 Dimcho Balev 2008-04-22 00:39:59 PDT
Created attachment 20745 [details]
First crude patch (mac only)

This is my first patch. I realize that it is Mac only and will break the windows build. I am also no sure if it modifies the right classes. I just wanted to have something concrete that will help having more focused  discussions.
Comment 2 Anders Carlsson 2008-04-22 17:03:32 PDT
The approach looks good and should work well on both Windows and Mac.

The patch does violate the Web Kit style guidelines described on http://webkit.org/coding/coding-style.html but other than that I think it is a great idea.
Comment 3 Dimcho Balev 2008-05-29 16:50:52 PDT
Created attachment 21423 [details]
Updated the patch with new constant name and value
Comment 4 Dimcho Balev 2008-07-15 18:59:25 PDT
Created attachment 22298 [details]
Fixed a bug about missing http status line. Added Windows/Linux code

- This patch includes the corresponding code for Windows/Linux that was absent from the previous patches (they updated the Mac version only).
- I also added a fix for windows specific bug about missing http status line from the http headers that webkit passes to the plugins.
- Some minor format changes
Comment 5 Anders Carlsson 2008-07-28 12:21:10 PDT
Comment 6 Anders Carlsson 2008-07-28 12:24:47 PDT
Comment on attachment 22298 [details]
Fixed a bug about missing http status line. Added Windows/Linux code

Looks great. I've committed it with a few tweaks. I haven't committed the Windows parts but that's next. 

(I didn't commit the header changes. Could you please file a new bug for that?)
Comment 7 Dimcho Balev 2008-07-28 14:59:34 PDT
Logged a separate bug for the missing status line on windows: Bug 20202
Comment 8 Anders Carlsson 2008-07-28 17:38:32 PDT
Committed revision 35417.