Annotation of libwww/Library/src/HTFormat.html, revision 2.65

2.10      timbl       1: <HTML>
                      2: <HEAD>
2.62      frystyk     3: <TITLE>W3C Reference Library libwww FORMAT NEGOTIATION</TITLE>
2.65    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen, 17-Apr-1996 -->
2.15      timbl       5: <NEXTID N="z18">
2.10      timbl       6: </HEAD>
2.1       timbl       7: <BODY>
2.27      frystyk     8: 
2.31      frystyk     9: <H1>The Format Manager</H1>
2.33      frystyk    10: 
                     11: <PRE>
                     12: /*
2.41      frystyk    13: **     (c) COPYRIGHT MIT 1995.
2.33      frystyk    14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
2.31      frystyk    17: 
                     18: Here we describe the functions of the HTFormat module which handles
                     19: conversion between different data representations. (In MIME parlance,
                     20: a representation is known as a content-type. In <A
2.46      frystyk    21: HREF="http://www.w3.org/pub/WWW/TheProject.html">WWW</A> the
2.64      frystyk    22: term <EM>format</EM> is often used as it is shorter).The content of
2.31      frystyk    23: this module is:
                     24: 
                     25: <UL>
2.64      frystyk    26: <LI><A HREF="#CT">Content Type Converters and Presenters</A>
                     27: <LI><A HREF="#CE">Content Encoders and Decoders</A>
                     28: <LI><A HREF="#charset">Content Charsets</A>
                     29: <LI><A HREF="#language">Natural Languages</A><P>
2.63      frystyk    30: 
2.64      frystyk    31: <LI><A HREF="#global">Global Preferences</A><P>
                     32: 
                     33: <LI><A HREF="#CTStack">The Content Type Stream Stack</A>
                     34: <LI><A HREF="#CEStack">Content Encoding Stream Stack</A>
                     35: <LI><A HREF="#CTEStack">Content Transfer Encoding Stream Stack</A><P>
                     36: 
2.42      frystyk    37: <LI><A HREF="#Rank">Content Negotiation</A>
2.31      frystyk    38: </UL>
                     39: 
                     40: This module is implemented by <A HREF="HTFormat.c">HTFormat.c</A>, and
2.49      frystyk    41: it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/"> W3C
                     42: Reference Library</A>.
2.27      frystyk    43: 
2.31      frystyk    44: <PRE>
                     45: #ifndef HTFORMAT_H
2.1       timbl      46: #define HTFORMAT_H
                     47: 
2.63      frystyk    48: #include "<A HREF="HTUtils.html">HTUtils.h</A>"
                     49: #include "<A HREF="HTStream.html">HTStream.h</A>"
                     50: #include "<A HREF="HTAtom.html">HTAtom.h</A>"
                     51: #include "<A HREF="HTList.html">HTList.h</A>"
                     52: #include "<A HREF="HTAnchor.html">HTAnchor.h</A>"
                     53: #include "<A HREF="HTReq.html">HTReq.h</A>"
2.31      frystyk    54: </PRE>
2.1       timbl      55: 
2.64      frystyk    56: <A NAME="CT"><H2>Content Type Converters and Presenters</H2></A>
2.18      luotonen   57: 
2.63      frystyk    58: This is the description of how we hande content types (media types)
                     59: 
2.64      frystyk    60: <H3>Content Type Converters</H3></A>
2.63      frystyk    61: 
2.42      frystyk    62: A <CODE><A NAME="z12">converter</A></CODE> is a stream with a special
                     63: set of parameters and which is registered as capable of converting
                     64: from a MIME type to something else (maybe another MIME-type). A
                     65: converter is defined to be a function returning a stream and accepting
                     66: the following parameters. The content type elements are atoms for
                     67: which we have defined a prototype.
2.18      luotonen   68: 
2.31      frystyk    69: <PRE>
2.52      frystyk    70: typedef HTStream * HTConverter (HTRequest *    request,
                     71:                                 void *         param,
                     72:                                 HTFormat       input_format,
                     73:                                 HTFormat       output_format,
                     74:                                 HTStream *     output_stream);
2.42      frystyk    75: </PRE>
2.18      luotonen   76: 
2.63      frystyk    77: <H3>The HTPresentation Object</H3>
2.31      frystyk    78: 
2.42      frystyk    79: A <CODE>presenter</CODE> is a module (possibly an external program)
                     80: which can present a graphic object of a certain MIME type to the
                     81: user. That is, <CODE>presenters</CODE> are normally used to present
                     82: objects that the <CODE>converters</CODE> are not able to handle. Data
                     83: is transferred to the external program using for example the <A
                     84: HREF="HTFWrite.html">HTSaveAndExecute</A> stream which writes to a
                     85: local file. Both presenters and converters are of the type <A
                     86: HREF="#converter">HTConverter</A>.
2.31      frystyk    87: 
                     88: <PRE>
2.42      frystyk    89: typedef struct _HTPresentation {
                     90:     HTFormat   rep;                         /* representation name atomized */
                     91:     HTFormat   rep_out;                         /* resulting representation */
                     92:     HTConverter *converter;          /* The routine to gen the stream stack */
                     93:     char *     command;                               /* MIME-format string */
                     94:     char *     test_command;                          /* MIME-format string */
                     95:     double     quality;                     /* Between 0 (bad) and 1 (good) */
                     96:     double     secs;
                     97:     double     secs_per_byte;
                     98: } HTPresentation;
2.28      frystyk    99: </PRE>
                    100: 
2.63      frystyk   101: <H3>Basic Content type Converters</H3>
2.28      frystyk   102: 
2.63      frystyk   103: We have a small set of basic converters that can be hooked in
                    104: anywhere. They don't "convert" anything but are nice to have.
                    105: 
                    106: <PRE>
                    107: extern HTConverter HTThroughLine;
                    108: extern HTConverter HTBlackHoleConverter;
                    109: </PRE>
                    110: 
                    111: <H3>Predefined Content Types</H3>
                    112: 
2.42      frystyk   113: These macros (which used to be constants) define some basic internally
                    114: referenced representations. The <CODE>www/xxx</CODE> ones are of
2.52      frystyk   115: course not MIME standard. They are internal representations used in
                    116: the Library but they can't be exported to other apps!
2.28      frystyk   117: 
                    118: <PRE>
2.57      frystyk   119: #define WWW_RAW                HTAtom_for("www/void")   /* Raw output from Protocol */
2.28      frystyk   120: </PRE>
                    121: 
2.57      frystyk   122: <CODE>WWW_RAW</CODE> is an output format which leaves the input
2.54      frystyk   123: untouched <EM>exactly</EM> as it is received by the protocol
                    124: module. For example, in the case of FTP, this format returns raw ASCII
                    125: objects for directory listings; for HTTP, everything including the
                    126: header is returned, for Gopher, a raw ASCII object is returned for a
                    127: menu etc.
2.10      timbl     128: 
2.28      frystyk   129: <PRE>
2.57      frystyk   130: #define WWW_SOURCE     HTAtom_for("*/*")   /* Almost what it was originally */
                    131: </PRE>
                    132: 
                    133: <CODE>WWW_SOURCE</CODE> is an output format which leaves the input
                    134: untouched <EM>exactly</EM> as it is received by the protocol module
                    135: <B>IF</B> not a suitable converter has been registered with a quality
                    136: factor higher than 1 (for example 2). In this case the <EM>SUPER
                    137: CONVERTER</EM> is preferred for the raw output. This can be used as a
                    138: filter effect that allows conversion from, for example raw
                    139: FTPdirectory listings into HTML but passes a MIME body untouched.
                    140: 
                    141: <PRE>
2.28      frystyk   142: #define WWW_PRESENT    HTAtom_for("www/present")   /* The user's perception */
                    143: </PRE>
                    144: 
2.52      frystyk   145: <CODE>WWW_PRESENT</CODE> represents the user's perception of the
                    146: document.  If you convert to <CODE>WWW_PRESENT</CODE>, you present the
                    147: material to the user.
2.58      frystyk   148: 
                    149: <PRE>
                    150: #define WWW_DEBUG      HTAtom_for("www/debug")
                    151: </PRE>
                    152: 
                    153: <CODE>WWW_DEBUG</CODE> represents the user's perception of debug
                    154: information, for example sent as a HTML document in a HTTP redirection
                    155: message.
2.28      frystyk   156: 
                    157: <PRE>
2.52      frystyk   158: #define WWW_UNKNOWN     HTAtom_for("www/unknown")
2.28      frystyk   159: </PRE>
                    160: 
2.52      frystyk   161: <CODE>WWW_UNKNOWN</CODE> is a really unknown type. It differs from the
                    162: real MIME type <EM>"application/octet-stream"</EM> in that we haven't
                    163: even tried to figure out the content type at this point.<P>
2.28      frystyk   164: 
2.31      frystyk   165: These are regular MIME types defined. Others can be added!
2.28      frystyk   166: 
                    167: <PRE>
2.52      frystyk   168: #define WWW_HTML       HTAtom_for("text/html")
2.28      frystyk   169: #define WWW_PLAINTEXT  HTAtom_for("text/plain")
2.52      frystyk   170: 
                    171: #define WWW_MIME       HTAtom_for("message/rfc822")
2.60      frystyk   172: #define WWW_MIME_HEAD  HTAtom_for("message/x-rfc822-head")
2.65    ! frystyk   173: #define WWW_MIME_FOOT  HTAtom_for("message/x-rfc822-foot")
2.52      frystyk   174: 
2.10      timbl     175: #define WWW_AUDIO       HTAtom_for("audio/basic")
2.52      frystyk   176: 
2.26      frystyk   177: #define WWW_VIDEO      HTAtom_for("video/mpeg")
2.52      frystyk   178: 
2.38      frystyk   179: #define WWW_GIF        HTAtom_for("image/gif")
2.63      frystyk   180: #define WWW_JPEG       HTAtom_for("image/jpeg")
                    181: #define WWW_TIFF       HTAtom_for("image/tiff")
2.52      frystyk   182: #define WWW_PNG        HTAtom_for("image/png")
                    183: 
                    184: #define WWW_BINARY     HTAtom_for("application/octet-stream")
                    185: #define WWW_POSTSCRIPT         HTAtom_for("application/postscript")
                    186: #define WWW_RICHTEXT   HTAtom_for("application/rtf")
2.48      frystyk   187: </PRE>
                    188: 
2.52      frystyk   189: We also have some MIME types that come from the various protocols when
                    190: we convert from ASCII to HTML.
2.48      frystyk   191: 
                    192: <PRE>
                    193: #define WWW_GOPHER_MENU HTAtom_for("text/x-gopher")
2.53      frystyk   194: #define WWW_CSO_SEARCH HTAtom_for("text/x-cso")
2.48      frystyk   195: 
                    196: #define WWW_FTP_LNST   HTAtom_for("text/x-ftp-lnst")
                    197: #define WWW_FTP_LIST   HTAtom_for("text/x-ftp-list")
                    198: 
                    199: #define WWW_NNTP_LIST   HTAtom_for("text/x-nntp-list")
                    200: #define WWW_NNTP_OVER  HTAtom_for("text/x-nntp-over")
                    201: #define WWW_NNTP_HEAD  HTAtom_for("text/x-nntp-head")
2.59      frystyk   202: 
                    203: #define WWW_HTTP       HTAtom_for("text/x-http")
2.55      frystyk   204: </PRE>
                    205: 
                    206: Finally we have defined a special format for our RULE files as they
                    207: can be handled by a special converter.
                    208: 
                    209: <PRE>
2.57      frystyk   210: #define WWW_RULES      HTAtom_for("application/x-www-rules")
2.28      frystyk   211: </PRE>
                    212: 
2.63      frystyk   213: <H3>Register Presenters</H3>
2.50      frystyk   214: 
                    215: This function creates a presenter object and adds to the list of
                    216: conversions.
2.31      frystyk   217: 
2.1       timbl     218: <DL>
2.31      frystyk   219: <DT>conversions
                    220: <DD>The list of <CODE>conveters</CODE> and <CODE>presenters</CODE>
2.50      frystyk   221: <DT>rep_in
2.42      frystyk   222: <DD>the MIME-style format name
2.50      frystyk   223: <DT>rep_out
                    224: <DD>is the resulting content-type after the conversion
                    225: <DT>converter
                    226: <DD>is the routine to call which actually does the conversion
2.1       timbl     227: <DT>quality
2.31      frystyk   228: <DD>A degradation faction [0..1]
2.1       timbl     229: <DT>maxbytes
2.31      frystyk   230: <DD>A limit on the length acceptable as input (0 infinite)
2.1       timbl     231: <DT>maxsecs
2.31      frystyk   232: <DD>A limit on the time user will wait (0 for infinity)
2.1       timbl     233: </DL>
                    234: 
2.31      frystyk   235: <PRE>
2.49      frystyk   236: extern void HTPresentation_add (HTList *       conversions,
2.61      frystyk   237:                                const char *    representation,
                    238:                                const char *    command,
                    239:                                const char *    test_command,
2.49      frystyk   240:                                double          quality,
                    241:                                double          secs, 
                    242:                                double          secs_per_byte);
2.1       timbl     243: 
2.50      frystyk   244: extern void HTPresentation_deleteAll   (HTList * list);
                    245: </PRE>
                    246: 
2.63      frystyk   247: <H3>Register Converters</H3>
2.50      frystyk   248: 
                    249: This function creates a presenter object and adds to the list of
                    250: conversions.
2.1       timbl     251: 
                    252: <DL>
2.31      frystyk   253: <DT>conversions
                    254: <DD>The list of <CODE>conveters</CODE> and <CODE>presenters</CODE>
2.1       timbl     255: <DT>rep_in
2.42      frystyk   256: <DD>the MIME-style format name
2.1       timbl     257: <DT>rep_out
2.31      frystyk   258: <DD>is the resulting content-type after the conversion
2.1       timbl     259: <DT>converter
2.31      frystyk   260: <DD>is the routine to call which actually does the conversion
                    261: <DT>quality
                    262: <DD>A degradation faction [0..1]
                    263: <DT>maxbytes
                    264: <DD>A limit on the length acceptable as input (0 infinite)
                    265: <DT>maxsecs
                    266: <DD>A limit on the time user will wait (0 for infinity)
2.1       timbl     267: </DL>
                    268: 
                    269: <PRE>
2.49      frystyk   270: extern void HTConversion_add   (HTList *       conversions,
2.61      frystyk   271:                                const char *    rep_in,
                    272:                                const char *    rep_out,
2.49      frystyk   273:                                HTConverter *   converter,
                    274:                                double          quality,
                    275:                                double          secs, 
                    276:                                double          secs_per_byte);
2.63      frystyk   277: 
                    278: extern void HTConversion_deleteAll     (HTList * list);
2.42      frystyk   279: </PRE>
                    280: 
2.64      frystyk   281: <A NAME="CE"><H2>Content and Transfer Encoders and Decoders</H2>
2.50      frystyk   282: 
2.64      frystyk   283: Content codins are transformations applied to an entity object after
                    284: it was created in its original form. The Library handles two types of
                    285: codings:
2.63      frystyk   286: 
2.64      frystyk   287: <DL>
                    288: <DT><B>Content Codings</B>
                    289: <DD>Content codings values indicate an encoding transformation that
                    290: has been applied to a resource. Content cosings are primarily used to
                    291: allow a document to be compressed or encrypted without loosing the
                    292: identity of its underlying media type.
2.63      frystyk   293: 
2.64      frystyk   294: <DT><B>Content Transfer Codings</B>
                    295: <DD>Content transfer codings values are used to indicate an encoding
                    296: transformation that has been, can be, or may be need to be applied to
                    297: an enity body in order to ensure safe transport through the
                    298: network. This differs from a content coding in that the transfer
                    299: coding is a property of the message, not the original message.
                    300: </DL>
2.63      frystyk   301: 
2.64      frystyk   302: Both types of encodings use the same registration mechanism in the
                    303: Library which we describe below:
                    304: 
                    305: <H3>Encoders and Decoders</H3>
                    306: 
                    307: <EM>Encoders</EM> and <EM>decoders</EM> are subclassed from the <A
                    308: HREF="HTStream.html">generic stream class</A>. <EM>Encoders</EM> are
                    309: capable of adding a content coding to a data object and
                    310: <EM>decoders</EM> can remove a content coding.
                    311: 
2.50      frystyk   312: <PRE>
2.64      frystyk   313: typedef HTStream * HTCoder     (HTRequest *    request,
                    314:                                 void *         param,
                    315:                                 HTEncoding     coding,
                    316:                                 HTStream *     target);
2.50      frystyk   317: </PRE>
                    318: 
2.64      frystyk   319: The <EM>encoding</EM> is the name of the encoding mechanism
                    320: reporesented as an <A HREF="HTAtom.html">atom</A>, for example "zip",
                    321: "chunked", etc. Encodings are registered in lists and content
                    322: encodings are separated from transfer encodings by registering them in
                    323: different lists.
2.42      frystyk   324: 
2.64      frystyk   325: <H3>The HTCoding Object</H3>
                    326: 
                    327: The <EM>HTCoding</EM> object represents a registered encoding together
                    328: with a encoder and a decoder.
                    329: 
2.63      frystyk   330: <PRE>
2.64      frystyk   331: typedef struct _HTCoding HTCoding;
2.63      frystyk   332: </PRE>
                    333: 
                    334: <H3>Predefined Coding Types</H4>
                    335: 
2.64      frystyk   336: We have a set of pre defined atoms for various types of content
                    337: encodings and transfer encodings. "chunked" is not exactly in the same
                    338: group as the other encodings such as "binary" but it really doesn't
                    339: make any difference as it is just a matter of how the words are
                    340: chosen. The first three transfer encodings are actually not encodings
                    341: - they are just left overs from brain dead mail systems.
                    342: 
2.42      frystyk   343: <PRE>
2.63      frystyk   344: #define WWW_CTE_7BIT           HTAtom_for("7bit")
                    345: #define WWW_CTE_8BIT           HTAtom_for("8bit")
                    346: #define WWW_CTE_BINARY         HTAtom_for("binary")
2.64      frystyk   347: 
2.63      frystyk   348: #define WWW_CTE_BASE64         HTAtom_for("base64")
                    349: #define WWW_CTE_MACBINHEX      HTAtom_for("macbinhex")
2.64      frystyk   350: #define WWW_CTE_CHUNKED                HTAtom_for("chunked")
2.63      frystyk   351: 
                    352: #define WWW_CE_COMPRESS                HTAtom_for("compress")
                    353: #define WWW_CE_GZIP            HTAtom_for("gzip")
2.42      frystyk   354: </PRE>
                    355: 
2.63      frystyk   356: <H3>Register Content Coders</H3>
2.42      frystyk   357: 
2.63      frystyk   358: There is no difference in registrering a content encoder or a content decoder,
                    359: it all depends on how you use the list of encoders/decoders.
                    360: 
2.42      frystyk   361: <PRE>
2.64      frystyk   362: extern BOOL HTCoding_add (HTList *     list,
                    363:                         const char *   encoding,
                    364:                         HTCoder *      encoder,
                    365:                         HTCoder *      decoder,
                    366:                         double         quality);
2.63      frystyk   367: 
2.64      frystyk   368: extern void HTCoding_deleteAll (HTList * list);
2.42      frystyk   369: 
2.64      frystyk   370: extern const char * HTCoding_name (HTCoding * me);
2.42      frystyk   371: </PRE>
2.31      frystyk   372: 
2.63      frystyk   373: <H2><A NAME="charset">Content Charsets</A></H2>
                    374: 
2.64      frystyk   375: <H3>Register a Charset</H3>
2.42      frystyk   376: 
                    377: <PRE>
2.50      frystyk   378: extern void HTCharset_add (HTList *            list,
2.61      frystyk   379:                           const char *         charset,
2.50      frystyk   380:                           double               quality);
2.42      frystyk   381: </PRE>
                    382: 
2.64      frystyk   383: <H3>Delete a list of Charsets</H3>
2.42      frystyk   384: 
2.50      frystyk   385: <PRE>
2.63      frystyk   386: typedef struct _HTAcceptNode {
                    387:     HTAtom *   atom;
                    388:     double     quality;
                    389: } HTAcceptNode;
                    390: </PRE>
                    391: 
                    392: <PRE>
2.50      frystyk   393: extern void HTCharset_deleteAll        (HTList * list);
                    394: </PRE>
                    395: 
2.64      frystyk   396: <A NAME="language"><H2>Content Languages</H2></A>
2.31      frystyk   397: 
2.64      frystyk   398: <H3>Register a Language</H3>
2.31      frystyk   399: 
                    400: <PRE>
2.50      frystyk   401: extern void HTLanguage_add (HTList *           list,
2.61      frystyk   402:                            const char *        lang,
2.50      frystyk   403:                            double              quality);
                    404: </PRE>
                    405: 
2.64      frystyk   406: <H3>Delete a list of Languages</H3>
2.50      frystyk   407: 
                    408: <PRE>
2.51      frystyk   409: extern void HTLanguage_deleteAll (HTList * list);
2.50      frystyk   410: </PRE>
                    411: 
                    412: <A NAME="global"><H2>Global Registrations</H2></A>
                    413: 
                    414: There are two places where these preferences can be registered: in a
                    415: <EM>global</EM> list valid for <B>all</B> requests and a
                    416: <EM>local</EM> list valid for a particular request only. These are
                    417: valid for <EM>all</EM> requests. See the <A HREF="HTReq.html">Request
                    418: Manager</A> fro local sets.
                    419: 
2.51      frystyk   420: <H3>Converters and Presenters</H3>
2.50      frystyk   421: 
                    422: The <EM>global</EM> list of specific conversions which the format
                    423: manager can do in order to fulfill the request.  There is also a <A
                    424: HREF="HTReq.html"><EM>local</EM></A> list of conversions which
                    425: contains a generic set of possible conversions.
                    426: 
                    427: <PRE>
2.64      frystyk   428: extern void HTFormat_setConversion     (HTList * list);
2.50      frystyk   429: extern HTList * HTFormat_conversion    (void);
2.31      frystyk   430: </PRE>
                    431: 
2.64      frystyk   432: <H3>Content Codings</H3>
2.42      frystyk   433: 
2.50      frystyk   434: <PRE>
2.64      frystyk   435: extern void HTFormat_setContentCoding  (HTList * list);
                    436: extern HTList * HTFormat_contentCoding (void);
2.50      frystyk   437: </PRE>
2.1       timbl     438: 
2.64      frystyk   439: <H3>Content Transfer Codings</H3>
                    440: 
                    441: <PRE>
                    442: extern void HTFormat_setTransferCoding (HTList * list);
                    443: extern HTList * HTFormat_transferCoding        (void);
                    444: </PRE>
                    445: 
                    446: We also define a macro to find out whether a transfer encoding is
                    447: really an encoding or whether it is just a "dummy" as for example
                    448: 7bit, 8bit, and binary.
                    449: 
                    450: <PRE>
                    451: #define HTFormat_isUnityTransfer(me) \
                    452:        ((me)==NULL \
                    453:        || (me)==WWW_CTE_BINARY ||  (me)==WWW_CTE_7BIT || (me)==WWW_CTE_8BIT)
                    454: </PRE>
                    455: 
2.51      frystyk   456: <H3>Content Languages</H3>
2.50      frystyk   457: 
                    458: <PRE>
2.64      frystyk   459: extern void HTFormat_setLanguage       (HTList * list);
2.50      frystyk   460: extern HTList * HTFormat_language      (void);
                    461: </PRE>
2.42      frystyk   462: 
2.51      frystyk   463: <H3>Content Charsets</H3>
2.1       timbl     464: 
2.31      frystyk   465: <PRE>
2.64      frystyk   466: extern void HTFormat_setCharset                (HTList * list);
2.50      frystyk   467: extern HTList * HTFormat_charset       (void);
2.31      frystyk   468: </PRE>
                    469: 
2.50      frystyk   470: <H3>Delete All Global Lists</H3>
2.42      frystyk   471: 
2.50      frystyk   472: This is a convenience function that might make life easier.
2.34      frystyk   473: 
                    474: <PRE>
2.50      frystyk   475: extern void HTFormat_deleteAll (void);
2.34      frystyk   476: </PRE>
2.31      frystyk   477: 
                    478: <A NAME="Rank"><H2>Ranking of Accepted Formats</H2></A>
                    479: 
2.36      frystyk   480: This function is used when the best match among several possible
                    481: documents is to be found as a function of the accept headers sent in
                    482: the client request.
2.31      frystyk   483: 
                    484: <PRE>
2.42      frystyk   485: typedef struct _HTContentDescription {
                    486:     char *     filename;
2.63      frystyk   487:     HTFormat   content_type;
                    488:     HTLanguage content_language;
                    489:     HTEncoding content_encoding;
2.64      frystyk   490:     HTEncoding content_transfer;
2.42      frystyk   491:     int                content_length;
                    492:     double     quality;
                    493: } HTContentDescription;
                    494: 
2.52      frystyk   495: extern BOOL HTRank (HTList * possibilities,
                    496:                    HTList * accepted_content_types,
                    497:                    HTList * accepted_content_languages,
                    498:                    HTList * accepted_content_encodings);
2.1       timbl     499: </PRE>
2.31      frystyk   500: 
2.64      frystyk   501: <H2><A NAME="z3">The Content Type Stream Stack</A></H2>
2.31      frystyk   502: 
2.64      frystyk   503: This is the routine which actually sets up the content type
                    504: conversion. It currently checks only for direct conversions, but
                    505: multi-stage conversions are forseen.  It takes a stream into which the
                    506: output should be sent in the final format, builds the conversion
                    507: stack, and returns a stream into which the data in the input format
                    508: should be fed. If <CODE>guess</CODE> is true and input format is
2.31      frystyk   509: <CODE>www/unknown</CODE>, try to guess the format by looking at the
                    510: first few bytes of the stream. <P>
2.1       timbl     511: 
2.31      frystyk   512: <PRE>
2.52      frystyk   513: extern HTStream * HTStreamStack (HTFormat      rep_in,
                    514:                                 HTFormat       rep_out,
                    515:                                 HTStream *     output_stream,
                    516:                                 HTRequest *    request,
                    517:                                 BOOL           guess);
2.1       timbl     518: </PRE>
2.31      frystyk   519: 
2.63      frystyk   520: <H3>Cost of a Stream Stack</H3>
2.31      frystyk   521: 
                    522: Must return the cost of the same stack which HTStreamStack would set
2.1       timbl     523: up.
                    524: 
2.31      frystyk   525: <PRE>
2.52      frystyk   526: extern double HTStackValue     (HTList *       conversions,
                    527:                                 HTFormat       format_in,
                    528:                                 HTFormat       format_out,
                    529:                                 double         initial_value,
                    530:                                 long int       length);
2.64      frystyk   531: </PRE>
2.31      frystyk   532: 
2.64      frystyk   533: <A NAME="CEStack"><H2>Content Encoding Stream Stack</H2></A>
                    534: 
                    535: When creating a coding stream stack, it is important that we keep the
                    536: right order of encoders and decoders. As an example, the HTTP spec
                    537: specifies that the list in the <EM>Content-Encoding</EM> header
                    538: follows the order in which the encodings have been applied to the
                    539: object. Internally, we represent the content encodings as <A
                    540: HREF="HTAtom.html">atoms</A> in a linked <A HREF="HTList.html">list
                    541: object</A>.<P>
                    542: 
                    543: The creation of the content coding stack is not based on quality
                    544: factors as we don't have the freedom as with content types. When using
                    545: content codings we <EM>must</EM> apply the codings specified or fail.
                    546: 
                    547: <PRE>
                    548: extern HTStream * HTContentCodingStack (HTEncoding     coding,
                    549:                                        HTStream *      target,
                    550:                                        HTRequest *     request,
                    551:                                        void *          param,
                    552:                                        BOOL            encoding);
                    553: </PRE>
                    554: 
                    555: Here you can provide a complete list instead of a single token. The list has to
                    556: be filled up in the order the _encodings_ are to be applied
                    557: 
                    558: <PRE>
                    559: extern HTStream * HTContentEncodingStack (HTList *     encodings,
                    560:                                          HTStream *    target,
                    561:                                          HTRequest *   request,
                    562:                                          void *        param);
                    563: </PRE>
                    564: 
                    565: Here you can provide a complete list instead of a single token. The list has to
                    566: be in the order the _encodings_ were applied - that is, the same way that
                    567: _encodings_ are to be applied. This is all consistent with the order of the
                    568: Content-Encoding header.
                    569: 
                    570: <PRE>
                    571: extern HTStream * HTContentDecodingStack (HTList *     encodings,
                    572:                                          HTStream *    target,
                    573:                                          HTRequest *   request,
                    574:                                          void *        param);
                    575: </PRE>
                    576: 
                    577: <A NAME="CTEStack"><H2>Content Transfer Encoding Stream Stack</H2></A>
                    578: 
                    579: Creating the transfer content encoding stream stack is not based on
                    580: quality factors as we don't have the freedom as with content
                    581: types. Specify whether you you want encoding or decoding using the
                    582: BOOL "encode" flag.
                    583: 
                    584: <PRE>
                    585: extern HTStream * HTTransferCodingStack (HTEncoding    encoding,
                    586:                                         HTStream *     target,
                    587:                                         HTRequest *    request,
                    588:                                         void *         param,
                    589:                                         BOOL           encode);
                    590: </PRE>
                    591: 
                    592: <PRE>
2.42      frystyk   593: #endif /* HTFORMAT */
2.38      frystyk   594: </PRE>
                    595: 
2.63      frystyk   596: <HR>
                    597: <ADDRESS>
2.65    ! frystyk   598: @(#) $Id: HTFormat.html,v 2.64 1996/04/15 21:05:54 frystyk Exp $
2.63      frystyk   599: </ADDRESS>
2.31      frystyk   600: </BODY>
2.10      timbl     601: </HTML>

Webmaster