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

2.10      timbl       1: <HTML>
                      2: <HEAD>
2.62      frystyk     3: <TITLE>W3C Reference Library libwww FORMAT NEGOTIATION</TITLE>
2.64    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen, 15-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.52      frystyk   173: 
2.10      timbl     174: #define WWW_AUDIO       HTAtom_for("audio/basic")
2.52      frystyk   175: 
2.26      frystyk   176: #define WWW_VIDEO      HTAtom_for("video/mpeg")
2.52      frystyk   177: 
2.38      frystyk   178: #define WWW_GIF        HTAtom_for("image/gif")
2.63      frystyk   179: #define WWW_JPEG       HTAtom_for("image/jpeg")
                    180: #define WWW_TIFF       HTAtom_for("image/tiff")
2.52      frystyk   181: #define WWW_PNG        HTAtom_for("image/png")
                    182: 
                    183: #define WWW_BINARY     HTAtom_for("application/octet-stream")
                    184: #define WWW_POSTSCRIPT         HTAtom_for("application/postscript")
                    185: #define WWW_RICHTEXT   HTAtom_for("application/rtf")
2.48      frystyk   186: </PRE>
                    187: 
2.52      frystyk   188: We also have some MIME types that come from the various protocols when
                    189: we convert from ASCII to HTML.
2.48      frystyk   190: 
                    191: <PRE>
                    192: #define WWW_GOPHER_MENU HTAtom_for("text/x-gopher")
2.53      frystyk   193: #define WWW_CSO_SEARCH HTAtom_for("text/x-cso")
2.48      frystyk   194: 
                    195: #define WWW_FTP_LNST   HTAtom_for("text/x-ftp-lnst")
                    196: #define WWW_FTP_LIST   HTAtom_for("text/x-ftp-list")
                    197: 
                    198: #define WWW_NNTP_LIST   HTAtom_for("text/x-nntp-list")
                    199: #define WWW_NNTP_OVER  HTAtom_for("text/x-nntp-over")
                    200: #define WWW_NNTP_HEAD  HTAtom_for("text/x-nntp-head")
2.59      frystyk   201: 
                    202: #define WWW_HTTP       HTAtom_for("text/x-http")
2.55      frystyk   203: </PRE>
                    204: 
                    205: Finally we have defined a special format for our RULE files as they
                    206: can be handled by a special converter.
                    207: 
                    208: <PRE>
2.57      frystyk   209: #define WWW_RULES      HTAtom_for("application/x-www-rules")
2.28      frystyk   210: </PRE>
                    211: 
2.63      frystyk   212: <H3>Register Presenters</H3>
2.50      frystyk   213: 
                    214: This function creates a presenter object and adds to the list of
                    215: conversions.
2.31      frystyk   216: 
2.1       timbl     217: <DL>
2.31      frystyk   218: <DT>conversions
                    219: <DD>The list of <CODE>conveters</CODE> and <CODE>presenters</CODE>
2.50      frystyk   220: <DT>rep_in
2.42      frystyk   221: <DD>the MIME-style format name
2.50      frystyk   222: <DT>rep_out
                    223: <DD>is the resulting content-type after the conversion
                    224: <DT>converter
                    225: <DD>is the routine to call which actually does the conversion
2.1       timbl     226: <DT>quality
2.31      frystyk   227: <DD>A degradation faction [0..1]
2.1       timbl     228: <DT>maxbytes
2.31      frystyk   229: <DD>A limit on the length acceptable as input (0 infinite)
2.1       timbl     230: <DT>maxsecs
2.31      frystyk   231: <DD>A limit on the time user will wait (0 for infinity)
2.1       timbl     232: </DL>
                    233: 
2.31      frystyk   234: <PRE>
2.49      frystyk   235: extern void HTPresentation_add (HTList *       conversions,
2.61      frystyk   236:                                const char *    representation,
                    237:                                const char *    command,
                    238:                                const char *    test_command,
2.49      frystyk   239:                                double          quality,
                    240:                                double          secs, 
                    241:                                double          secs_per_byte);
2.1       timbl     242: 
2.50      frystyk   243: extern void HTPresentation_deleteAll   (HTList * list);
                    244: </PRE>
                    245: 
2.63      frystyk   246: <H3>Register Converters</H3>
2.50      frystyk   247: 
                    248: This function creates a presenter object and adds to the list of
                    249: conversions.
2.1       timbl     250: 
                    251: <DL>
2.31      frystyk   252: <DT>conversions
                    253: <DD>The list of <CODE>conveters</CODE> and <CODE>presenters</CODE>
2.1       timbl     254: <DT>rep_in
2.42      frystyk   255: <DD>the MIME-style format name
2.1       timbl     256: <DT>rep_out
2.31      frystyk   257: <DD>is the resulting content-type after the conversion
2.1       timbl     258: <DT>converter
2.31      frystyk   259: <DD>is the routine to call which actually does the conversion
                    260: <DT>quality
                    261: <DD>A degradation faction [0..1]
                    262: <DT>maxbytes
                    263: <DD>A limit on the length acceptable as input (0 infinite)
                    264: <DT>maxsecs
                    265: <DD>A limit on the time user will wait (0 for infinity)
2.1       timbl     266: </DL>
                    267: 
                    268: <PRE>
2.49      frystyk   269: extern void HTConversion_add   (HTList *       conversions,
2.61      frystyk   270:                                const char *    rep_in,
                    271:                                const char *    rep_out,
2.49      frystyk   272:                                HTConverter *   converter,
                    273:                                double          quality,
                    274:                                double          secs, 
                    275:                                double          secs_per_byte);
2.63      frystyk   276: 
                    277: extern void HTConversion_deleteAll     (HTList * list);
2.42      frystyk   278: </PRE>
                    279: 
2.64    ! frystyk   280: <A NAME="CE"><H2>Content and Transfer Encoders and Decoders</H2>
2.50      frystyk   281: 
2.64    ! frystyk   282: Content codins are transformations applied to an entity object after
        !           283: it was created in its original form. The Library handles two types of
        !           284: codings:
2.63      frystyk   285: 
2.64    ! frystyk   286: <DL>
        !           287: <DT><B>Content Codings</B>
        !           288: <DD>Content codings values indicate an encoding transformation that
        !           289: has been applied to a resource. Content cosings are primarily used to
        !           290: allow a document to be compressed or encrypted without loosing the
        !           291: identity of its underlying media type.
2.63      frystyk   292: 
2.64    ! frystyk   293: <DT><B>Content Transfer Codings</B>
        !           294: <DD>Content transfer codings values are used to indicate an encoding
        !           295: transformation that has been, can be, or may be need to be applied to
        !           296: an enity body in order to ensure safe transport through the
        !           297: network. This differs from a content coding in that the transfer
        !           298: coding is a property of the message, not the original message.
        !           299: </DL>
2.63      frystyk   300: 
2.64    ! frystyk   301: Both types of encodings use the same registration mechanism in the
        !           302: Library which we describe below:
        !           303: 
        !           304: <H3>Encoders and Decoders</H3>
        !           305: 
        !           306: <EM>Encoders</EM> and <EM>decoders</EM> are subclassed from the <A
        !           307: HREF="HTStream.html">generic stream class</A>. <EM>Encoders</EM> are
        !           308: capable of adding a content coding to a data object and
        !           309: <EM>decoders</EM> can remove a content coding.
        !           310: 
2.50      frystyk   311: <PRE>
2.64    ! frystyk   312: typedef HTStream * HTCoder     (HTRequest *    request,
        !           313:                                 void *         param,
        !           314:                                 HTEncoding     coding,
        !           315:                                 HTStream *     target);
2.50      frystyk   316: </PRE>
                    317: 
2.64    ! frystyk   318: The <EM>encoding</EM> is the name of the encoding mechanism
        !           319: reporesented as an <A HREF="HTAtom.html">atom</A>, for example "zip",
        !           320: "chunked", etc. Encodings are registered in lists and content
        !           321: encodings are separated from transfer encodings by registering them in
        !           322: different lists.
2.42      frystyk   323: 
2.64    ! frystyk   324: <H3>The HTCoding Object</H3>
        !           325: 
        !           326: The <EM>HTCoding</EM> object represents a registered encoding together
        !           327: with a encoder and a decoder.
        !           328: 
2.63      frystyk   329: <PRE>
2.64    ! frystyk   330: typedef struct _HTCoding HTCoding;
2.63      frystyk   331: </PRE>
                    332: 
                    333: <H3>Predefined Coding Types</H4>
                    334: 
2.64    ! frystyk   335: We have a set of pre defined atoms for various types of content
        !           336: encodings and transfer encodings. "chunked" is not exactly in the same
        !           337: group as the other encodings such as "binary" but it really doesn't
        !           338: make any difference as it is just a matter of how the words are
        !           339: chosen. The first three transfer encodings are actually not encodings
        !           340: - they are just left overs from brain dead mail systems.
        !           341: 
2.42      frystyk   342: <PRE>
2.63      frystyk   343: #define WWW_CTE_7BIT           HTAtom_for("7bit")
                    344: #define WWW_CTE_8BIT           HTAtom_for("8bit")
                    345: #define WWW_CTE_BINARY         HTAtom_for("binary")
2.64    ! frystyk   346: 
2.63      frystyk   347: #define WWW_CTE_BASE64         HTAtom_for("base64")
                    348: #define WWW_CTE_MACBINHEX      HTAtom_for("macbinhex")
2.64    ! frystyk   349: #define WWW_CTE_CHUNKED                HTAtom_for("chunked")
2.63      frystyk   350: 
                    351: #define WWW_CE_COMPRESS                HTAtom_for("compress")
                    352: #define WWW_CE_GZIP            HTAtom_for("gzip")
2.42      frystyk   353: </PRE>
                    354: 
2.63      frystyk   355: <H3>Register Content Coders</H3>
2.42      frystyk   356: 
2.63      frystyk   357: There is no difference in registrering a content encoder or a content decoder,
                    358: it all depends on how you use the list of encoders/decoders.
                    359: 
2.42      frystyk   360: <PRE>
2.64    ! frystyk   361: extern BOOL HTCoding_add (HTList *     list,
        !           362:                         const char *   encoding,
        !           363:                         HTCoder *      encoder,
        !           364:                         HTCoder *      decoder,
        !           365:                         double         quality);
2.63      frystyk   366: 
2.64    ! frystyk   367: extern void HTCoding_deleteAll (HTList * list);
2.42      frystyk   368: 
2.64    ! frystyk   369: extern const char * HTCoding_name (HTCoding * me);
2.42      frystyk   370: </PRE>
2.31      frystyk   371: 
2.63      frystyk   372: <H2><A NAME="charset">Content Charsets</A></H2>
                    373: 
2.64    ! frystyk   374: <H3>Register a Charset</H3>
2.42      frystyk   375: 
                    376: <PRE>
2.50      frystyk   377: extern void HTCharset_add (HTList *            list,
2.61      frystyk   378:                           const char *         charset,
2.50      frystyk   379:                           double               quality);
2.42      frystyk   380: </PRE>
                    381: 
2.64    ! frystyk   382: <H3>Delete a list of Charsets</H3>
2.42      frystyk   383: 
2.50      frystyk   384: <PRE>
2.63      frystyk   385: typedef struct _HTAcceptNode {
                    386:     HTAtom *   atom;
                    387:     double     quality;
                    388: } HTAcceptNode;
                    389: </PRE>
                    390: 
                    391: <PRE>
2.50      frystyk   392: extern void HTCharset_deleteAll        (HTList * list);
                    393: </PRE>
                    394: 
2.64    ! frystyk   395: <A NAME="language"><H2>Content Languages</H2></A>
2.31      frystyk   396: 
2.64    ! frystyk   397: <H3>Register a Language</H3>
2.31      frystyk   398: 
                    399: <PRE>
2.50      frystyk   400: extern void HTLanguage_add (HTList *           list,
2.61      frystyk   401:                            const char *        lang,
2.50      frystyk   402:                            double              quality);
                    403: </PRE>
                    404: 
2.64    ! frystyk   405: <H3>Delete a list of Languages</H3>
2.50      frystyk   406: 
                    407: <PRE>
2.51      frystyk   408: extern void HTLanguage_deleteAll (HTList * list);
2.50      frystyk   409: </PRE>
                    410: 
                    411: <A NAME="global"><H2>Global Registrations</H2></A>
                    412: 
                    413: There are two places where these preferences can be registered: in a
                    414: <EM>global</EM> list valid for <B>all</B> requests and a
                    415: <EM>local</EM> list valid for a particular request only. These are
                    416: valid for <EM>all</EM> requests. See the <A HREF="HTReq.html">Request
                    417: Manager</A> fro local sets.
                    418: 
2.51      frystyk   419: <H3>Converters and Presenters</H3>
2.50      frystyk   420: 
                    421: The <EM>global</EM> list of specific conversions which the format
                    422: manager can do in order to fulfill the request.  There is also a <A
                    423: HREF="HTReq.html"><EM>local</EM></A> list of conversions which
                    424: contains a generic set of possible conversions.
                    425: 
                    426: <PRE>
2.64    ! frystyk   427: extern void HTFormat_setConversion     (HTList * list);
2.50      frystyk   428: extern HTList * HTFormat_conversion    (void);
2.31      frystyk   429: </PRE>
                    430: 
2.64    ! frystyk   431: <H3>Content Codings</H3>
2.42      frystyk   432: 
2.50      frystyk   433: <PRE>
2.64    ! frystyk   434: extern void HTFormat_setContentCoding  (HTList * list);
        !           435: extern HTList * HTFormat_contentCoding (void);
2.50      frystyk   436: </PRE>
2.1       timbl     437: 
2.64    ! frystyk   438: <H3>Content Transfer Codings</H3>
        !           439: 
        !           440: <PRE>
        !           441: extern void HTFormat_setTransferCoding (HTList * list);
        !           442: extern HTList * HTFormat_transferCoding        (void);
        !           443: </PRE>
        !           444: 
        !           445: We also define a macro to find out whether a transfer encoding is
        !           446: really an encoding or whether it is just a "dummy" as for example
        !           447: 7bit, 8bit, and binary.
        !           448: 
        !           449: <PRE>
        !           450: #define HTFormat_isUnityTransfer(me) \
        !           451:        ((me)==NULL \
        !           452:        || (me)==WWW_CTE_BINARY ||  (me)==WWW_CTE_7BIT || (me)==WWW_CTE_8BIT)
        !           453: </PRE>
        !           454: 
2.51      frystyk   455: <H3>Content Languages</H3>
2.50      frystyk   456: 
                    457: <PRE>
2.64    ! frystyk   458: extern void HTFormat_setLanguage       (HTList * list);
2.50      frystyk   459: extern HTList * HTFormat_language      (void);
                    460: </PRE>
2.42      frystyk   461: 
2.51      frystyk   462: <H3>Content Charsets</H3>
2.1       timbl     463: 
2.31      frystyk   464: <PRE>
2.64    ! frystyk   465: extern void HTFormat_setCharset                (HTList * list);
2.50      frystyk   466: extern HTList * HTFormat_charset       (void);
2.31      frystyk   467: </PRE>
                    468: 
2.50      frystyk   469: <H3>Delete All Global Lists</H3>
2.42      frystyk   470: 
2.50      frystyk   471: This is a convenience function that might make life easier.
2.34      frystyk   472: 
                    473: <PRE>
2.50      frystyk   474: extern void HTFormat_deleteAll (void);
2.34      frystyk   475: </PRE>
2.31      frystyk   476: 
                    477: <A NAME="Rank"><H2>Ranking of Accepted Formats</H2></A>
                    478: 
2.36      frystyk   479: This function is used when the best match among several possible
                    480: documents is to be found as a function of the accept headers sent in
                    481: the client request.
2.31      frystyk   482: 
                    483: <PRE>
2.42      frystyk   484: typedef struct _HTContentDescription {
                    485:     char *     filename;
2.63      frystyk   486:     HTFormat   content_type;
                    487:     HTLanguage content_language;
                    488:     HTEncoding content_encoding;
2.64    ! frystyk   489:     HTEncoding content_transfer;
2.42      frystyk   490:     int                content_length;
                    491:     double     quality;
                    492: } HTContentDescription;
                    493: 
2.52      frystyk   494: extern BOOL HTRank (HTList * possibilities,
                    495:                    HTList * accepted_content_types,
                    496:                    HTList * accepted_content_languages,
                    497:                    HTList * accepted_content_encodings);
2.1       timbl     498: </PRE>
2.31      frystyk   499: 
2.64    ! frystyk   500: <H2><A NAME="z3">The Content Type Stream Stack</A></H2>
2.31      frystyk   501: 
2.64    ! frystyk   502: This is the routine which actually sets up the content type
        !           503: conversion. It currently checks only for direct conversions, but
        !           504: multi-stage conversions are forseen.  It takes a stream into which the
        !           505: output should be sent in the final format, builds the conversion
        !           506: stack, and returns a stream into which the data in the input format
        !           507: should be fed. If <CODE>guess</CODE> is true and input format is
2.31      frystyk   508: <CODE>www/unknown</CODE>, try to guess the format by looking at the
                    509: first few bytes of the stream. <P>
2.1       timbl     510: 
2.31      frystyk   511: <PRE>
2.52      frystyk   512: extern HTStream * HTStreamStack (HTFormat      rep_in,
                    513:                                 HTFormat       rep_out,
                    514:                                 HTStream *     output_stream,
                    515:                                 HTRequest *    request,
                    516:                                 BOOL           guess);
2.1       timbl     517: </PRE>
2.31      frystyk   518: 
2.63      frystyk   519: <H3>Cost of a Stream Stack</H3>
2.31      frystyk   520: 
                    521: Must return the cost of the same stack which HTStreamStack would set
2.1       timbl     522: up.
                    523: 
2.31      frystyk   524: <PRE>
2.52      frystyk   525: extern double HTStackValue     (HTList *       conversions,
                    526:                                 HTFormat       format_in,
                    527:                                 HTFormat       format_out,
                    528:                                 double         initial_value,
                    529:                                 long int       length);
2.64    ! frystyk   530: </PRE>
2.31      frystyk   531: 
2.64    ! frystyk   532: <A NAME="CEStack"><H2>Content Encoding Stream Stack</H2></A>
        !           533: 
        !           534: When creating a coding stream stack, it is important that we keep the
        !           535: right order of encoders and decoders. As an example, the HTTP spec
        !           536: specifies that the list in the <EM>Content-Encoding</EM> header
        !           537: follows the order in which the encodings have been applied to the
        !           538: object. Internally, we represent the content encodings as <A
        !           539: HREF="HTAtom.html">atoms</A> in a linked <A HREF="HTList.html">list
        !           540: object</A>.<P>
        !           541: 
        !           542: The creation of the content coding stack is not based on quality
        !           543: factors as we don't have the freedom as with content types. When using
        !           544: content codings we <EM>must</EM> apply the codings specified or fail.
        !           545: 
        !           546: <PRE>
        !           547: extern HTStream * HTContentCodingStack (HTEncoding     coding,
        !           548:                                        HTStream *      target,
        !           549:                                        HTRequest *     request,
        !           550:                                        void *          param,
        !           551:                                        BOOL            encoding);
        !           552: </PRE>
        !           553: 
        !           554: Here you can provide a complete list instead of a single token. The list has to
        !           555: be filled up in the order the _encodings_ are to be applied
        !           556: 
        !           557: <PRE>
        !           558: extern HTStream * HTContentEncodingStack (HTList *     encodings,
        !           559:                                          HTStream *    target,
        !           560:                                          HTRequest *   request,
        !           561:                                          void *        param);
        !           562: </PRE>
        !           563: 
        !           564: Here you can provide a complete list instead of a single token. The list has to
        !           565: be in the order the _encodings_ were applied - that is, the same way that
        !           566: _encodings_ are to be applied. This is all consistent with the order of the
        !           567: Content-Encoding header.
        !           568: 
        !           569: <PRE>
        !           570: extern HTStream * HTContentDecodingStack (HTList *     encodings,
        !           571:                                          HTStream *    target,
        !           572:                                          HTRequest *   request,
        !           573:                                          void *        param);
        !           574: </PRE>
        !           575: 
        !           576: <A NAME="CTEStack"><H2>Content Transfer Encoding Stream Stack</H2></A>
        !           577: 
        !           578: Creating the transfer content encoding stream stack is not based on
        !           579: quality factors as we don't have the freedom as with content
        !           580: types. Specify whether you you want encoding or decoding using the
        !           581: BOOL "encode" flag.
        !           582: 
        !           583: <PRE>
        !           584: extern HTStream * HTTransferCodingStack (HTEncoding    encoding,
        !           585:                                         HTStream *     target,
        !           586:                                         HTRequest *    request,
        !           587:                                         void *         param,
        !           588:                                         BOOL           encode);
        !           589: </PRE>
        !           590: 
        !           591: <PRE>
2.42      frystyk   592: #endif /* HTFORMAT */
2.38      frystyk   593: </PRE>
                    594: 
2.63      frystyk   595: <HR>
                    596: <ADDRESS>
2.64    ! frystyk   597: @(#) $Id: HTFormat.html,v 2.63 1996/04/12 17:47:03 frystyk Exp $
2.63      frystyk   598: </ADDRESS>
2.31      frystyk   599: </BODY>
2.10      timbl     600: </HTML>

Webmaster