NPAPI:HTTPRedirectHandling: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 22: Line 22:


* instance: the plug-in instance that made the request
* instance: the plug-in instance that made the request
* url: the new redirected url
* url: the new target url for the redirect
* status: the status code returned from the server (will be 3xx)
* status: the status code returned from the server (will be 3xx)
* notifyData: the data passed into NPN_PostURLNotify() or NPN_GetURLNotify()
* notifyData: the data passed into NPN_PostURLNotify() or NPN_GetURLNotify()
Line 30: Line 30:
   NPVERS_HAS_HTTP_REDIRECT_HANDLER = 26
   NPVERS_HAS_HTTP_REDIRECT_HANDLER = 26


The slot for this handler in the plugin function structure can be NULL. If this function is not provided then redirect behavior is up to the browser. Most existing browser implementations simply allow all redirects though this is not guaranteed to be the case.
The slot for this handler in the plugin function structure can be NULL. If this function is not provided then redirect behavior is up to the browser. The recommended default behavior is to allow all same-origin redirects and disallow all cross-origin redirects.


Plugins should return "NPERR_NO_ERR" when the redirect is to be allowed. There may be further redirect notifications when a redirect is allowed. Any return value other than "NPERR_NO_ERR" will disallow the redirect and the browser will subsequently issue an "NPP_URLNotify" call with reason "NPRES_USER_BREAK" and the last redirected url (the same one passed to the NPP_URLNotifyRedirect the last time)
Plugins should return "NPERR_NO_ERR" when the redirect is to be allowed. There may be further redirect notifications when a redirect is allowed. Any return value other than "NPERR_NO_ERR" will disallow the redirect and the browser will subsequently issue an "NPP_URLNotify" call with reason "NPRES_USER_BREAK" and the last redirected url (the same one passed to the NPP_URLNotifyRedirect the last time)

Revision as of 21:13, 11 October 2010

Status

Under consideration.

Contributors

  • Last modified: October 8, 2010
  • Authors: Rudi Sherry (Adobe), Josh Aas (Mozilla), Johnny Stenback (Mozilla)
  • Contributors: Darin Fisher (Google), Dimcho Balev (Adobe), Deneb Meketa (Adobe), Stuart Morgan (Google)

Overview

Plugins need the opportunity to participate in HTTP redirect handling for requests started with 'NPN_PostURLNotify' and 'NPN_GetURLNotify'.

Specification

The following function can be implemented by plugins to allow for HTTP redirect handling:

 int32 NPP_URLNotifyRedirect(NPP instance, const char* url,
                             int32 status, void* notifyData);
  • instance: the plug-in instance that made the request
  • url: the new target url for the redirect
  • status: the status code returned from the server (will be 3xx)
  • notifyData: the data passed into NPN_PostURLNotify() or NPN_GetURLNotify()

The browser will look for this handler only if the plugin function structure's version field is set to the following value or higher:

 NPVERS_HAS_HTTP_REDIRECT_HANDLER = 26

The slot for this handler in the plugin function structure can be NULL. If this function is not provided then redirect behavior is up to the browser. The recommended default behavior is to allow all same-origin redirects and disallow all cross-origin redirects.

Plugins should return "NPERR_NO_ERR" when the redirect is to be allowed. There may be further redirect notifications when a redirect is allowed. Any return value other than "NPERR_NO_ERR" will disallow the redirect and the browser will subsequently issue an "NPP_URLNotify" call with reason "NPRES_USER_BREAK" and the last redirected url (the same one passed to the NPP_URLNotifyRedirect the last time)

Plugins can query the browser for support for this specification using the following variable:

 NPNVsupportsRedirectNotification = 22

If the browser returns "true" for this variable then plugins can depend on the browser calling the HTTP redirect handler when appropriate, if it is provided by the plugin.