home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
srev13g.zip
/
MULTSEND.DOC
< prev
next >
Wrap
Text File
|
1999-03-16
|
9KB
|
186 lines
16 February 1999
The SREF_MULTI_SEND macrospace procedure of the SRE-http Web Server
SREF_MULTI_SEND is used to create multi-part document. It can also
be used to "send pieces" of a document as it becomes available.
* Multi-part documents are used for "server push" delivery of several files
sequentially. The basic presumption of a multi-part document is that
each part stand's on it's own. Typically, a browser will replace an earlier
part as soon as the next part becomes available. For example,
server push can be used as a form of animation, with each part being
a "frame" of a movie.
For example, the GIF_TEXT addon uses multi-part document to build
complicated images, with simpler images displayed first, which
are then replaced by more elaborate versions.
Multi-part documents require browsers that are able to maintain
connections, and that understand the multipart/x-mixed-replace mimetype.
Older browsers, such as Web Explorer, can not do this.
* Sending pieces is used to send earlier portions of a document as
they become available. This gives the client something to read when
long documents are being built on-the-fly. For example, the BBS
addon uses "sending in pieces" to display long listings, that
might "time out" the server (or the client's attention span)
if nothing is sent before the entire listing is created.
Send-in-pieces documents can be handled by all browsers.
By using SREF_MULTI_SEND, it's easy to create "multi-part"
or "send as pieces" documents. All you need to do is specify a list of
files (or strings), and let SREF_MULTI_SEND take care of the grubby details.
I. Using SREF_MULTI_SEND
The basic syntax of SREF_MULTI_SEND is:
rcode=sref_multi_send(message,mime_type,howsend,file_flag,verbose)
where:
message: either contains the "message" to be sent (either a text string or
binary value); OR a fully qualified file name.
mime_type : A mime type; such as text/html or image/gif
You can also use mime_type to send additional response headers
(see the notes below).
howsend : A flag that tells SRE-http "where in the multi-send process
we are". There are basically four values (with
possible modifiers):
'1' == Single part document to "send in pieces" (requires
a modifier)
'S' == Start the multipart send (i.e.; the first image)
'M' == A middle piece -- more will follow
'E' == End piece -- send this "message" and close the connection.
In addition, you can "build" a long message, and display
each portion as soon as they are added. To do this, use the
following HowSend codes:
'1S' and '1E' -- Start and end a "sent in pieces" single part
document
'SS' and 'SE' -- Start and end the first "part"
'MS' and 'ME' -- Start and end the middle "part(s)"
'ES' and 'EE' -- Start and end the final "part"
'A' and '1A' -- Add stuff (between 1S-1E; SS-SE ; MS-ME; or ES-EE)
fileflag: If equal to 1, then "message" is to be treated as a
fully-qualified file name (Optional)
verbose : If > 2, some status info will be displayed (optional)
name : Name to use when writing to GoServe audit file (for future
implementation)
Notes:
* The return code (rcode) is the RC from the 'SEND' command: you can
check for negative values which indicate a broken connection.
* x and xS are the same (where x=1,S,M, or E.
In particular: 1S=1, SS=S, MS=M, and ES=E.
* name is ONLY used on "first calls".
In particular, when howsend=1, 1S, S, or SS.
* mime_type is only used on "first calls of a part".
In particular, when howsend=1, 1S, S, SS, M, MS, E, or ES.
* If howsend='A', the name and mime_type arguments are ignored.
* If mime_type is not specified, text/html is assumed.
* If howsend is not specified, A is assumed.
* In most cases, the mime_type argument should contain a mime-type,
such as image/gif, text/html, etc. However, you can also use
the mime_type argument to add additional response headers for a "part".
To do this, append (after the mime-type) a '0d0a'x (a CRLF), followed
by a list (CRLF delimited) of response headers.
Examples:
mime_type='image/gif'||'0d0a'x||'Content-Disposition: attachment; filename=MySTUFF.GIF'
mime_type='text/plain'||'0d0a'x||'X-my_header: Hello1'||'0d0a'x||'X-his-header: goodbye'
Note that:
i) the mime-type (for example, the 'image/gif') MUST be first,
ii) the mime-type must be immediately followed by a '0d0a'x.
iii) you should NOT end the string with a '0d0a'x.
Examples:
A 3 picture animation:
foo=sref_multi_send('d:\i1.gif','image/gif','S',1)
foo=sref_multi_send('d:\i2.gif','image/gif','M',1)
foo=sref_multi_send('d:\i3.gif','image/gif','E',1)
A 3 screen status report, with the middle portion a "running tally"
foo=sref_multi_send('Welcome','text/plain','S')
foo=sref_multi_send('Part 1 is done','text/plain','MS')
foo=sref_multi_send('Part 2 is done','text/plain','A')
foo=sref_multi_send('Part 3 is done','text/plain','ME')
foo=sref_multi_send('good bye','text/plain','E')
A 5 piece single part document:
foo=sref_multi_send(' This is the first line,'text/plain','1S')
foo=sref_multi_send(' This is line 2 ','text/plain','1A')
foo=sref_multi_send(' This is line 3 ','text/plain','1A')
foo=sref_multi_send(' This is line 4 ','text/plain','1A')
foo=sref_multi_send(' This is the last line ','text/plain','1E')
Simple usage:
foo=sref_multi_send('<h2>Technical Notes</h2>')
is the same as
foo=sref_multi_send('<h2>Technical Notes</h2>',,'A')
(note that the second argument is ignored when howsend='A')
For a longer example, see http://www.srehttp.org/addons/multsend?
II. Technical Notes
Multi-Part Documents:
When ever you issue a S (or SS), M (or MS), or E (or ES) command,
SRE will assume that you are "starting a part" .
Specifically, xS (x=S,M, or E) will start a new part of a
"multi part document". On the other hand, xE will close this part.
Upon recieving a "new part", multipart aware browsers (such as
netscape 2.0 and above) will "remove old stuff". This might mean
clearing the screen (or frame); or clearing the box within
which an in-line image is drawn.
In contrast, "A" means "add new content" -- it never generates a new
document. "A" can be used with any browser, since it does
not require multi-part awareness. Note that using A with non-text
information should work (i.e.; streaming audio), but has not
been tested.
Therefore, "animated" documents (or images) should be generated by
using:
1) "S" -- which sends the appropriate "this is a multi-part document"
headers to the browser, as well as the file/string you specify,
2) one one more "M" --which sends a seperator line and the
file/string), and
3) "E" -- which sends the file/string, and closes the multi-part document.
If one of these (S, M, or E) will be sent in pieces (with each piece
appended to previously sent portions of the "part"), then you should use
a series of xS, A ... A,xE (where x is S,M or E) calls.
Single Part Document Sent In Pieces:
Single part documents are more generally understood (by older
browsers). The calling sequence should be 1S, 1A,..,1A,1E.
Notes:
* You can use a sequence of SS, A, SE to send-in-pieces
a single part document, but it's not recommended (GoServe
may not close the document properly)
* As with multi-part documents, you can use as many "1A" calls
as needed.
* A '1' and a '1S' have the same effect (starting a "send in
pieces" document).
* You can NOT intermix "1x" with "SX", "Mx", or "Ex".
* You should always end a "send in pieces" document with
a '1E'.
Expiration note:
As of ver 1.3a, the FIX_EXPIRE "correction" is automatically handled
when SREF_MULTI_SEND is first invoked (with a '1S', 'S', or 'SS').