NPAPI:HTTPRedirectHandling: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:
= Specification =
= Specification =


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


   void NPP_URLRedirectNotify(NPP instance, const char* url,
   void NPP_URLRedirectNotify(NPP instance, const char* url,
Line 28: Line 28:
The browser will look for 'NPP_URLRedirectNotify' only if the plugin function structure's version field is set to the following value or higher:
The browser will look for 'NPP_URLRedirectNotify' only if the plugin function structure's version field is set to the following value or higher:


   NPVERS_HAS_HTTP_REDIRECT_HANDLER = 26
   NPVERS_HAS_URL_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.
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 respond to HTTP redirect request by calling the following function in the browser's function table:
Plugins must respond to URL redirect requests by calling the following function in the browser's function table:


   void NPN_HTTPRedirectResponse(NPP instance, void* notifyData, NPBool allow);
   void NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow);


* instance: The plug-in instance that made the request.
* instance: The plug-in instance that made the request.
* notifyData: The plugin's private request data.
* notifyData: The plugin's private request data.
* allow: The plugin's response to the last HTTP redirect request.
* allow: The plugin's response to the last URL redirect request.


This function must be available if the browser has called 'NPP_URLRedirectNotify' on the plugin.
This function must be available if the browser has called 'NPP_URLRedirectNotify' on the plugin.


Network requests may time out if a response is not received in a reasonable amount of time. 'NPN_HTTPRedirectResponse' can be called during the call to 'NPP_URLRedirectNotify'.
Network requests may time out if a response is not received in a reasonable amount of time. 'NPN_URLRedirectResponse' can be called during the call to 'NPP_URLRedirectNotify'.


There may be further redirect notifications when a redirect is allowed. When a redirect is disallowed or an asynchronous redirect response is not received within a reasonable amount of time the browser will subsequently issue an 'NPP_URLNotify' call with reason 'NPRES_USER_BREAK' and the last allowed or original url.
There may be further redirect notifications when a redirect is allowed. When a redirect is disallowed or an asynchronous redirect response is not received within a reasonable amount of time the browser will subsequently issue an 'NPP_URLNotify' call with reason 'NPRES_USER_BREAK' and the last allowed or original url.


Plugins can query the browser for support for this specification using the following variable:
Plugins can query the browser for support for this specification by examining the browser's function table. If the version number is equal to or higher than 'NPVERS_HAS_URL_REDIRECT_HANDLER' and the slot for 'NPN_URLRedirectResponse' is non-NULL then the browser will call 'NPP_URLRedirectNotify' when appropriate.
 
  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.

Revision as of 03:26, 12 October 2010

Status

Under consideration.

Contributors

  • Last modified: October 11, 2010
  • Authors: Josh Aas (Mozilla), Johnny Stenback (Mozilla)
  • Contributors: Rudi Sherry (Adobe), 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 URL redirect handling:

 void NPP_URLRedirectNotify(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 plugin's private request data.

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

 NPVERS_HAS_URL_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 must respond to URL redirect requests by calling the following function in the browser's function table:

 void NPN_URLRedirectResponse(NPP instance, void* notifyData, NPBool allow);
  • instance: The plug-in instance that made the request.
  • notifyData: The plugin's private request data.
  • allow: The plugin's response to the last URL redirect request.

This function must be available if the browser has called 'NPP_URLRedirectNotify' on the plugin.

Network requests may time out if a response is not received in a reasonable amount of time. 'NPN_URLRedirectResponse' can be called during the call to 'NPP_URLRedirectNotify'.

There may be further redirect notifications when a redirect is allowed. When a redirect is disallowed or an asynchronous redirect response is not received within a reasonable amount of time the browser will subsequently issue an 'NPP_URLNotify' call with reason 'NPRES_USER_BREAK' and the last allowed or original url.

Plugins can query the browser for support for this specification by examining the browser's function table. If the version number is equal to or higher than 'NPVERS_HAS_URL_REDIRECT_HANDLER' and the slot for 'NPN_URLRedirectResponse' is non-NULL then the browser will call 'NPP_URLRedirectNotify' when appropriate.