« Gecko Plugin API Reference « Plug-in Side Plug-in API
Represents a stream of data either produced by the browser and consumed by the plug-in, or produced by the plug-in and consumed by the browser.
typedef struct _NPStream
{
void* pdata; /* plug-in private data */
void* ndata; /* Netscape private data */
const char* url;
uint32 end;
uint32 lastmodified;
void* notifyData;
const char *headers;
} NPStream;
The data structure has the following fields: Plug-in-private value that the plug-in can use to store a pointer to private data associated with the instance; not modified by the browser.
NPVERS_HAS_RESPONSE_HEADERS. This field is used only for HTTP and is null for other types of streams. The plug-in should copy this data before making use of it. The headers include the HTTP status line and all headers, verbatim as received from the server. Lines are terminated by newline characters ("\n"), and the headers are terminated by a newline followed by null ("\n\0").
The browser allocates and initializes the NPStream object and passes it to the plug-in in as a parameter to NPP_NewStream or NPN_NewStream. The browser cannot delete the object until after it calls NPP_DestroyStream or the plug-in calls NPN_DestroyStream.
Streams produced by the browser: the browser creates the NPStream object and passes it to the plug-in initially as a parameter to NPP_NewStream. All API calls that operate on the stream (such as NPP_WriteReady and NPP_Write) use a pointer to this stream. The browser informs the plug-in when the stream is about to be deleted through NPP_DestroyStream, after which the NPStream object is no longer valid.
Streams produced by the plug-in: the browser creates the NPStream object and returns it as an output parameter when the plug-in calls NPP_NewStream. The plug-in must pass a pointer to the NPStream to all API calls that operate on the stream, such as NPN_Write and NPN_DestroyStream.
Page last modified 22:47, 7 Mar 2008 by Sheppy