mozilla

Revision 171033 of NPStream

  • Revision slug: NPStream
  • Revision title: NPStream
  • Revision id: 171033
  • Created:
  • Creator: Sheppy
  • Is current revision? Yes
  • Comment /* Fields */ document headers field
Tags: 

Revision Content

{{ Np-plugin-api() }}

Summary

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.

Syntax

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;

Fields

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.

ndata
Browser-private value that can store data associated with the instance; should not be modified by the plug-in.
url
The URL that the data in the stream is read from or written to.
end
Offset in bytes of the end of the stream (equivalent to the length of the stream in bytes). Can be zero for streams of unknown length, such as streams returned from older FTP servers or generated "on the fly" by CGI scripts.
lastmodified
Time the data in the URL was last modified (if applicable), measured in seconds since 12:00 midnight GMT, January 1, 1970.
notifyData
Used only for streams generated in response to a NPN_GetURLNotify or NPN_PostURLNotify request.
headers
The response headers from the host. This field is only available if the NP version is greater than or equal to 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").

Description

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.

See Also

NPP_NewStream, NPP_DestroyStream, NPP_DestroyStream

Revision Source

<p>
{{ Np-plugin-api() }}
</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>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.
</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre>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;
</pre>
<h3 id="Fields" name="Fields">Fields</h3>
<p>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.
</p>
<dl><dt>ndata
</dt><dd>Browser-private value that can store data associated with the instance; should not be modified by the plug-in.
</dd></dl>
<dl><dt>url
</dt><dd>The URL that the data in the stream is read from or written to.
</dd></dl>
<dl><dt>end
</dt><dd>Offset in bytes of the end of the stream (equivalent to the length of the stream in bytes). Can be zero for streams of unknown length, such as streams returned from older FTP servers or generated "on the fly" by CGI scripts.
</dd></dl>
<dl><dt>lastmodified
</dt><dd>Time the data in the URL was last modified (if applicable), measured in seconds since 12:00 midnight GMT, January 1, 1970.
</dd></dl>
<dl><dt>notifyData
</dt><dd>Used only for streams generated in response to a NPN_GetURLNotify or NPN_PostURLNotify request.
<ul><li> For these streams, notifyData is set to the value of the notifyData parameter to <a href="en/NPN_GetURLNotify">NPN_GetURLNotify</a> or <a href="en/NPN_PostURLNotify">NPN_PostURLNotify</a>.
</li><li> For other streams, notifyData is null.
</li></ul>
</dd></dl>
<dl><dt>headers
</dt><dd>The response headers from the host. This field is only available if the NP version is greater than or equal to <code>NPVERS_HAS_RESPONSE_HEADERS</code>. 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").
</dd></dl>
<h3 id="Description" name="Description">Description</h3>
<p>The browser allocates and initializes the <code>NPStream object</code> and passes it to the plug-in in as a parameter to <a href="en/NPP_NewStream">NPP_NewStream</a> or <a href="en/NPN_NewStream">NPN_NewStream</a>. The browser cannot delete the object until after it calls <a href="en/NPP_DestroyStream">NPP_DestroyStream</a> or the plug-in calls <a href="en/NPN_DestroyStream">NPN_DestroyStream</a>.
</p><p>Streams produced by the browser: the browser creates the <code>NPStream</code> 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 <a href="en/NPP_WriteReady">NPP_WriteReady</a> and <a href="en/NPP_Write">NPP_Write</a>) use a pointer to this stream. The browser informs the plug-in when the stream is about to be deleted through <a href="en/NPP_DestroyStream">NPP_DestroyStream</a>, after which the <code>NPStream</code> object is no longer valid.
</p><p>Streams produced by the plug-in: the browser creates the <code>NPStream object</code> and returns it as an output parameter when the plug-in calls <a href="en/NPP_NewStream">NPP_NewStream</a>. The plug-in must pass a pointer to the NPStream to all API calls that operate on the stream, such as <a href="en/NPN_Write">NPN_Write</a> and <a href="en/NPN_DestroyStream">NPN_DestroyStream</a>.
</p>
<h3 id="See_Also" name="See_Also">See Also</h3>
<p><a href="en/NPP_NewStream">NPP_NewStream</a>, <a href="en/NPP_DestroyStream">NPP_DestroyStream</a>, <a href="en/NPP_DestroyStream">NPP_DestroyStream</a>
</p>
Revert to this revision