1 /*
2 
3   					W3C Sample Code Library libwww MIME Parsers
4 
5 
6 !
7   Libwww MIME Parsers
8 !
9 */
10 
11 /*
12 **	(c) COPYRIGHT MIT 1995.
13 **	Please first read the full copyright statement in the file COPYRIGH.
14 */
15 
16 /*
17 
18 The MIME parser stream presents a MIME document with a header and possibly
19 a footer. It recursively invokes the format manager to handle embedded formats
20 like MIME multipart. As well as stripping off and parsing the headers, the
21 MIME parser has to parse any weird MIME encodings it may meet within the
22 body parts of messages, and must deal with multipart
23 messages (see HTBound.h).
24 
25 This module is implemented to the level necessary for operation with WWW,
26 but is not currently complete for any arbitrary MIME message.
27 
28 This module is implemented by HTMIME.c, and it is
29 a part of the  W3C Sample Code
30 Library.
31 */
32 
33 #ifndef HTMIME_H
34 #define HTMIME_H
35 
36 #include "HTStream.h"
37 #include "HTFormat.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44 .
45   How to Deal with Unknown Data
46 .
47 
48 When the MIME parser can't find a target stream, for example because the
49 media type is unknown, or it has a content encoding or transfer encoding
50 that it doesn't know about then it has to get rid of the data in some other
51 fashion, for example by dumping it to local disk (but it could also be dumping
52 it to a black hole). The following two functions allow you to set and get
53 the stream to use in this situation. By default, libwww provides an
54 implementation of a save stream as HTSaveLocally
55 which you may want to use - this is for example used by the
56 current profiles.
57 */
58 
59 extern void HTMIME_setSaveStream (HTConverter * save_stream);
60 extern HTConverter * HTMIME_saveStream (void);
61 
62 /*
63 .
64   MIME Parse Stream
65 .
66 
67 This stream parses a complete MIME message and if a media type header is
68 found then the stream stack is called to create the nest stream instance
69 in the stream pipe. Any piece of the MIME body is pumped right through the
70 stream.
71 */
72 
73 extern HTConverter HTMIMEConvert;
74 
75 /*
76 .
77   MIME Header ONLY Parse Stream
78 .
79 
80 This stream parses a complete MIME header and then returnes
81 HT_LOADED. It does not set up any streams and resting data stays
82 in the buffer. This can be used if you only want to parse the headers before
83 you decide what to do next. This is for example the case with HTTP HEAD requests.
84 */
85 
86 extern HTConverter HTMIMEHeader;
87 
88 /*
89 .
90   MIME Footer ONLY Parse Stream
91 .
92 
93 Parse only a footer, for example after a chunked encoding.
94 */
95 
96 extern HTConverter HTMIMEFooter;
97 
98 /*
99 .
100   HTTP 100 Continue Parse Stream
101 .
102 
103 The 100 continue status codes can come at any time - we take them and put
104 the data down a temporary stream. When the 100 continue message has been
105 parsed, the stream returns HT_CONTINUE
106 */
107 
108 extern HTConverter HTMIMEContinue;
109 
110 /*
111 .
112   HTTP 101 Switching Protocol Parse Stream
113 .
114 
115 The 101 Switching Protocol status code indicates that the rest of the stream
116 is using another format, protocol, what ever. The result is the same - we
117 are done parsing here and must leave the rest to the next stream which hopefully
118 knows more about how to parse the rest of the stream. The stream stack is
119 called to look for a stream registered for handling
120 WWW_MIME_UPGRADE. This steam should
121 return HT_LOADED when it is done, HT_ERROR if an
122 error occurred and HT_OK as long as it just reads more data.
123 */
124 
125 extern HTConverter HTMIMEUpgrade;
126 
127 /*
128 .
129   HTTP 206 Partial Data MIME Parse Stream
130 .
131 
132 In case we sent a Range conditional GET we may get back a 206 Partial
133 Response. This response must be appended to the already existing cache entry
134 before presented to the user. That is, first we load the
135 cached object and pump it down the pipe and then
136 the new data follows. Only the latter part gets appended to the cache, of
137 course.
138 */
139 
140 extern HTConverter HTMIMEPartial;
141 
142 /*
143 .
144  HTMIME_anchor2response
145 .
146 
147 Copies the anchor HTTP headers into a response object by means
148 of the generic _dispatchParsers function. Written so that we can
149 copy the HTTP headers stored in the cache to the response object.
150 */
151 
152 #ifndef NO_CACHE
153 extern HTConverter HTCacheCopyHeaders;
154 #endif
155 
156 /*
157 */
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif  /* HTMIME_H */
164 
165 /*
166 
167 
168 
169   @(#) $Id$
170 
171 */
172