NPAPI:HTTPRedirectHandling: Difference between revisions

Jump to navigation Jump to search
Line 19: Line 19:


   /* Callback function type used by NPP_URLRedirectNotify */
   /* Callback function type used by NPP_URLRedirectNotify */
   typedef NPError (*NPN_HTTPRedirectResponseFunc)(NPP instance,
   typedef void (*NPN_HTTPRedirectResponseFunc)(NPP instance,
                                                  void* notifyData,
                                              void* notifyData,
                                                  NPBool allow);
                                              NPBool allow);
    
    
   NPError NPP_URLRedirectNotify(NPP instance, const char* url,
   void NPP_URLRedirectNotify(NPP instance, const char* url,
                                int32 status, void* notifyData,
                            int32 status, void* notifyData,
                                NPN_HTTPRedirectResponseFunc callback);
                            NPN_HTTPRedirectResponseFunc callback);


* instance: The plug-in instance that made the request.
* instance: The plug-in instance that made the request.
Line 39: Line 39:
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 have the option of synchronously or asynchronously responding to the redirect notification.
Network requests may time out if a response is not received in a reasonable amount of time. The asynchronous callback can be made from within 'NPP_URLRedirectNotify'.
 
Returning 'NPERR_NO_ERR' will synchronously allow the redirect, returning 'NPERR_INVALID_URL' will synchronously disallow the redirect. To respond asynchronously via the provided callback function plugins can return a newly defined error:
 
  #define NPERR_ASYNC_RESPONSE (NPERR_BASE + 14)
 
Network requests may time out if an asynchronous response is not received in a reasonable amount of time.


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.
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits

Navigation menu