home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13h.zip / MULTSEND.DOC < prev    next >
Text File  |  2001-03-27  |  10KB  |  234 lines

  1. 31 March 2000
  2.  
  3.    The SREF_MULTI_SEND macrospace procedure of the SRE-http Web Server
  4.  
  5. SREF_MULTI_SEND is used to create a multi-part document. It can also
  6. be used to "send pieces" of a document as it becomes available.
  7.  
  8.   * Multi-part documents are used for "server push" delivery of several files
  9.     sequentially. The basic presumption of a multi-part document is that
  10.     each part stand's on its own. Typically, a browser will replace an earlier 
  11.     part as soon as the next part becomes available. For example, 
  12.     server push can be used as a form of animation, with each part being
  13.     a "frame" of a movie. Alternatively, server push can be used to send
  14.     a "get ready" document, followed by a selected file, and lastly
  15.     a thank you.
  16.     
  17.     For example, the GIF_TEXT addon uses multi-part document to build
  18.     complicated images, with simpler images displayed first, which 
  19.     are then replaced by more elaborate versions.
  20.  
  21.          Multi-part documents require browsers that are able to maintain
  22.          connections, and that understand the multipart/mixed-replace mimetype.
  23.          Internet-ancient browsers, such as Web Explorer, can not do this.
  24.  
  25.   * Sending pieces is used to send earlier portions of a document as 
  26.     they become available. This gives the client something to read when
  27.     long documents are being built on-the-fly. For example, the BBS
  28.     addon uses "sending in pieces" to display long listings, that
  29.     might "time out" the server (or the client's attention span)
  30.     if nothing is sent before the entire listing is created.
  31.         
  32.        Send-in-pieces documents can be handled by all browsers.
  33.  
  34.  
  35. By using SREF_MULTI_SEND, it's easy to create "multi-part" 
  36. or "send as pieces" documents. All you need to do is specify a list of 
  37. files (or strings), and let SREF_MULTI_SEND take care of the grubby details.
  38.  
  39.  
  40. I. Using SREF_MULTI_SEND 
  41.  
  42. The basic syntax of SREF_MULTI_SEND is:
  43.   rcode=sref_multi_send(message,mime_type,howsend,file_flag,verbose,audnam,resp_hdr,part_hdr)
  44.  
  45. where:
  46.  
  47.    message:  either contains the "message" to be sent (text or non-text);
  48.              OR a fully qualified file name (whose contents will be read
  49.              and sent)
  50.    mime_type : A mime type; such as text/html or image/gif
  51.                You can also use mime_type to send additional response headers
  52.                (see the notes below).
  53.    howsend : A flag that tells SRE-http "where in the multi-send process
  54.              we are".  There are basically four values (with 
  55.              possible modifiers):
  56.               '1' == Single part document to "send in pieces" (requires
  57.                      a modifier)
  58.               'S' == Start the multipart send (i.e.; the first image)
  59.               'M' == A middle piece -- more will follow
  60.               'E' == End piece -- send this "message" and close the connection.
  61.                
  62.              In addition, you can "build" a long message, and display 
  63.              each portion as soon as they are added.  To do this, use the
  64.              following HowSend codes:
  65.                 '1S' and '1E' -- Start and end a "sent in pieces" single part
  66.                                  document
  67.                 'SS' and 'SE' -- Start and end the first "part"
  68.                 'MS' and 'ME' -- Start and end the middle "part(s)"
  69.                 'ES' and 'EE' -- Start and end the final "part"
  70.                 'A'  and '1A' -- Add stuff (between 1S-1E; SS-SE ; MS-ME; or ES-EE)
  71.  
  72.   fileflag: If equal to 1, then "message" is to be treated as a
  73.             fully-qualified file name (Optional)
  74.  
  75.    verbose : If > 2, some status info will be displayed (optional)
  76.  
  77.   audnam   : Name to use when writing to GoServe audit file (for future 
  78.              implementation)
  79.  
  80.  resp_hdr  : Optional list of response headers-- to add before the first part.
  81.              If more then one header, then each header should be
  82.              seperated by a CRLF, but there should NOT be a CRLF at the end 
  83.              of this string.
  84.              Note that as of 1.3h.0300.c, "part headers" are specified with
  85.              the part_hdr argument.
  86.  
  87.   part_hdr : Optional list of part specific response headers
  88.              See the technical notes below for details on resp_hdr and part_hdr.
  89.               
  90.  
  91. Notes:
  92.   * The return code (rcode) is the RC from the 'SEND' command: you can
  93.     check for negative values which  indicate a broken connection.
  94.  
  95.   * MULTSEND.CMD demos the use of SREF_MULTI_SEND.
  96.  
  97.   * x and xS are the same (where x=1,S,M, or E.
  98.     In particular: 1S=1, SS=S, MS=M, and ES=E.
  99.  
  100.   * audnam is ONLY used on "first calls".
  101.     In particular, when howsend=1, 1S, S, or SS.
  102.  
  103.   * mime_type is only used on "first calls of a part".
  104.     In particular, when howsend=1, 1S, S, SS, M, MS, E, or ES.
  105.  
  106.   * If howsend='A', the name and mime_type arguments are ignored.
  107.  
  108.   * If mime_type is not specified, text/html is assumed.
  109.  
  110.   * If howsend is not specified, A is assumed.
  111.  
  112.   * We no longer recommend using the mime_type argument to send additional
  113.     "part specific" headers -- you should use the part_hdr argument instead
  114.     (as explained below).
  115.  
  116. Examples:
  117. A 3 picture animation:
  118.         foo=sref_multi_send('d:\i1.gif','image/gif','S',1)
  119.         foo=sref_multi_send('d:\i2.gif','image/gif','M',1)
  120.         foo=sref_multi_send('d:\i3.gif','image/gif','E',1)
  121.  
  122. A 3 screen status report, with the middle portion a "running tally"
  123.         foo=sref_multi_send('Welcome','text/plain','S',,,, ,
  124.                              'HEADER ADD X-1: Welcome','X-part0: Yes ')
  125.         foo=sref_multi_send('Part 1 is done','text/plain','MS',,,,  ,
  126.                              ,'X-part1: On ')
  127.         foo=sref_multi_send('Part 2 is done',,'A')
  128.         foo=sref_multi_send('Part 3 is done',,'ME')
  129.         foo=sref_multi_send('good bye','text/plain','E')
  130.  
  131. A 5 piece single part document:
  132.         foo=sref_multi_send(' This is the first line,'text/plain','1S')
  133.         foo=sref_multi_send(' This is line 2 ',,'1A')
  134.         foo=sref_multi_send(' This is line 3 ',,'1A')
  135.         foo=sref_multi_send(' This is line 4 ',,'1A')
  136.         foo=sref_multi_send(' This is the last line  ','text/plain','1E')
  137.  
  138. Simple usage:
  139.         foo=sref_multi_send('<h2>This is line 3')
  140.            is the same as
  141.         foo=sref_multi_send('<h2>This is line 3',,'A')
  142.         (note that the second argument is ignored when howsend='A')
  143.  
  144. For a longer example, see MULTSEND.CMD
  145.  
  146.  
  147. II. Technical Notes 
  148.  
  149.  
  150. Using the RESP_HDR and PART_HDR arguments
  151.  
  152.    RESP_HDR is used to add response headers to your response. These are added
  153.    before the body (of a single part document), or before the first part
  154.    (of a multi-part document).
  155.  
  156.    The RESP_HDER argument is ONLY used with "beginning" parts -- 
  157.    when howtype = '1','1S','S', or 'SS'.
  158.    The form of the RESP_HDR should be similar to the form used in 
  159.    advanced options -- a CRLF delimited list, with each line starting with 
  160.    either 'HEADER ADD or 'HEADER DROP.
  161.     For example:
  162.        resp_hdrs='HEADER ADD X_1: This is X1 '||'0d0a'x||'HEADER Drop Expires'
  163.     Note that both ADD and DROP are supported.
  164.  
  165.     PART_HDR is used to add "part specific" headers (these are less 
  166.     frequently used).  PART_HDR is used in "first parts" -- when
  167.     howtype='S', 'SS', 'M', 'MS', 'E', or 'ES'
  168.  
  169.     PART_HDR also uses a CRLF delimited list, which will be 
  170.     added to the "head" of the part as is. Thus, you should NOT
  171.     include the 'HEADER ADD.  Furthermore, HEADER DROP is NOT supported.
  172.     For example:
  173.        hdrs='PART_NEW: This is another part '||'0d0a'x||'Content-Disp: keep'
  174.  
  175.     Lastly, if either PART_HDR or RESP_HDR argument is specified in a 
  176.     "middle" or "end" part (such as when howtype='A','SE', etc'), it will 
  177.     be ignored.
  178.  
  179.   
  180. Multi-Part Documents:
  181.   When ever you issue a S (or SS), M (or MS), or E (or ES) command,
  182.   SRE will assume that you are "starting a part" .  
  183.   Specifically, xS (x=S,M, or E) will start a new part of a  
  184.   "multi part document".  On the other hand, xE will close this part.
  185.  
  186.   Upon recieving a "new part", multipart aware browsers (such as 
  187.   netscape 2.0 and  above) will "remove old stuff". This might mean
  188.   clearing the screen (or frame); or clearing the box within
  189.   which an in-line image is drawn.
  190.  
  191.   In contrast, "A" means "add new content" -- it never generates a new
  192.   document.  "A" can be used with any browser, since it does
  193.   not require multi-part awareness. Note that using A with non-text 
  194.   information should work (i.e.; streaming audio), but has not 
  195.   been tested.
  196.  
  197.   Therefore, "animated" documents (or images) should be generated by
  198.   using:
  199.   1) "S" -- which sends the appropriate "this is a multi-part document" 
  200.             headers to the browser, as well as the file/string you specify, 
  201.   2) one one more "M"  --which sends a seperator line and the 
  202.                          file/string), and
  203.   3) "E" -- which sends the file/string, and closes the multi-part document.
  204.  
  205. If one of these (S, M, or E) will be sent in pieces (with each piece
  206. appended to previously sent portions of the "part"), then you should use 
  207. a series of xS, A ... A,xE (where x is S,M or E) calls.
  208.  
  209. Single Part Document Sent In Pieces:
  210.    Single part documents are more generally understood (by older
  211.    browsers). The calling sequence should be 1S, 1A,..,1A,1E.
  212.    Notes:
  213.      *    You can use a sequence of SS, A, SE to send-in-pieces
  214.           a single part document, but it's not recommended (GoServe
  215.           may not close the document properly)
  216.      *    As with multi-part documents, you can use as many "1A" calls 
  217.           as needed.
  218.      *    A '1' and a '1S' have the same effect (starting a "send in          
  219.           pieces" document).
  220.      *    You can NOT intermix "1x"  with "SX", "Mx", or "Ex".
  221.      *    You should always end a "send in pieces" document with
  222.           a '1E'.
  223.           
  224.    
  225.    
  226. Expiration note:
  227.  
  228.    As of ver 1.3a, the FIX_EXPIRE "correction" is automatically handled
  229.    when SREF_MULTI_SEND is first invoked (with a '1S', 'S', or 'SS').
  230.  
  231.  
  232.         
  233.  
  234.