~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Documentation/gsdoc/GSMimeParser.html

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<html><head>
2
 
 <title>GSMimeParser</title>
3
 
</head>
4
 
<body>
5
 
<a href ="GSMimeDocument.html">[Previous] </a>
6
 
<a href ="GSMime.html">[Up] </a>
7
 
<h1>GSMimeParser</h1>
8
 
<h3>Authors </h3>
9
 
 <dl>
10
 
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
11
 
<dd>
12
 
</dl>
13
 
<p>Version: $Revision: 1.15 $</p>
14
 
<p>Date: $Date: 2001/12/12 14:10:12 $</p>
15
 
<h2><a name ="cont-0">GSMimeParser</a></h2>
16
 
<h2><a name ="GSMimeParser">GSMimeParser</a></h2>
17
 
<p><b>Declared in: </b> Foundation/GSMime.h</p>
18
 
<p><b>Inherits from: </b> NSObject</p>
19
 
<p><b>Conforms to: </b> NSObject
20
 
</p>
21
 
<hr>
22
 
 
23
 
          <p>
24
 
 
25
 
            This class provides support for parsing MIME messages
26
 
            into GSMimeDocument objects.  Each parser object maintains
27
 
            an associated document into which data is stored.
28
 
          </p>
29
 
 
30
 
          <p>
31
 
 
32
 
            You supply the document to be parsed as one or more data
33
 
            items passed to the <code>Parse:</code> method, and (if
34
 
            the method always returns <code>YES</code>, you give it
35
 
            a final <code>nil</code> argument to mark the end of the
36
 
            document.
37
 
          </p>
38
 
 
39
 
          <p>
40
 
 
41
 
            On completion of parsing a valid document, the
42
 
            <code>document</code> method returns the resulting parsed document.
43
 
          </p>
44
 
 
45
 
        
46
 
<h2>Instance Variables </h2>
47
 
<ul>
48
 
</ul>
49
 
<h2>Methods </h2>
50
 
<ul>
51
 
<li ><a href ="GSMimeParser.html#method-0">+mimeParser</a>
52
 
<li ><a href ="GSMimeParser.html#method-1">-contextFor:</a>
53
 
<li ><a href ="GSMimeParser.html#method-2">-data</a>
54
 
<li ><a href ="GSMimeParser.html#method-3">-decodeData:fromRange:intoData:withContext:</a>
55
 
<li ><a href ="GSMimeParser.html#method-4">-document</a>
56
 
<li ><a href ="GSMimeParser.html#method-5">-isComplete</a>
57
 
<li ><a href ="GSMimeParser.html#method-6">-isInBody</a>
58
 
<li ><a href ="GSMimeParser.html#method-7">-isInHeaders</a>
59
 
<li ><a href ="GSMimeParser.html#method-8">-parse:</a>
60
 
<li ><a href ="GSMimeParser.html#method-9">-parseHeader:</a>
61
 
<li ><a href ="GSMimeParser.html#method-10">-parsingHeaders</a>
62
 
<li ><a href ="GSMimeParser.html#method-11">-scanHeader:named:inTo:</a>
63
 
<li ><a href ="GSMimeParser.html#method-12">-scanSpace:</a>
64
 
<li ><a href ="GSMimeParser.html#method-13">-scanSpecial:</a>
65
 
<li ><a href ="GSMimeParser.html#method-14">-scanToken:</a>
66
 
</ul>
67
 
<hr><h2>Class Methods </h2>
68
 
<h3><a name ="method-0">mimeParser</a></h3>
69
 
+ (GSMimeParser*) <b>mimeParser</b>;<br>
70
 
 
71
 
            Create a parser.
72
 
          
73
 
 <hr>
74
 
<hr><h2>Instances Methods </h2>
75
 
<h3><a name ="method-1">contextFor:</a></h3>
76
 
- (GSMimeCodingContext*) <b>contextFor:</b> (NSDictionary*)headerInfo;<br>
77
 
 
78
 
            Return a coding context object to be used for decoding data
79
 
            according to the scheme specified in the header.
80
 
            <p>
81
 
 
82
 
              The default implementation supports the following transfer
83
 
              encodings specified in either a <code>transfer-encoding</code>
84
 
              of <code>content-transfer-encoding</code> header -
85
 
            </p>
86
 
 
87
 
            <ul>
88
 
<li >base64
89
 
<li >quoted-printable
90
 
<li >binary
91
 
<li >7bit
92
 
<li >8bit
93
 
<li >chunked (for HTTP/1.1)
94
 
</ul>
95
 
 
96
 
          
97
 
 <hr>
98
 
<h3><a name ="method-2">data</a></h3>
99
 
- (NSData*) <b>data</b>;<br>
100
 
 
101
 
            Return the data accumulated in the parser.  If the parser is
102
 
            still parsing headers, this will be the header data read so far.
103
 
            If the parse has parsed the body of the message, this will be
104
 
            the data of the body, with any transfer encoding removed.
105
 
          
106
 
 <hr>
107
 
<h3><a name ="method-3">decodeData:fromRange:intoData:withContext:</a></h3>
108
 
- (BOOL) <b>decodeData:</b> (NSData*)sourceData <b>fromRange:</b> (NSRange)aRange <b>intoData:</b> (NSMutableData*)destinationData <b>withContext:</b> (GSMimeCodingContext*)ctxt;<br>
109
 
 
110
 
            <p>
111
 
 
112
 
              Decodes the raw data from the specified range in the source
113
 
              data object and appends it to the destination data object.
114
 
              The context object provides information about the content
115
 
              encoding type in use, and the state of the decoding operation.
116
 
            </p>
117
 
 
118
 
            <p>
119
 
 
120
 
              This method may be called repeatedly to incrementally decode
121
 
              information as it arrives on some communications channel.
122
 
              It should be called with a nil source data item (or with
123
 
              the atEnd flag of the context set to YES) in order to flush
124
 
              any information held in the context to the output data
125
 
              object.
126
 
            </p>
127
 
 
128
 
            <p>
129
 
 
130
 
              You may override this method in order to implement
131
 
              additional coding schemes.
132
 
            </p>
133
 
 
134
 
          
135
 
 <hr>
136
 
<h3><a name ="method-4">document</a></h3>
137
 
- (GSMimeDocument*) <b>document</b>;<br>
138
 
 
139
 
            Returns the object into which raw mime data is being parsed.
140
 
          
141
 
 <hr>
142
 
<h3><a name ="method-5">isComplete</a></h3>
143
 
- (BOOL) <b>isComplete</b>;<br>
144
 
 
145
 
            Returns YES if the document parsing is known to be completed.
146
 
          
147
 
 <hr>
148
 
<h3><a name ="method-6">isInBody</a></h3>
149
 
- (BOOL) <b>isInBody</b>;<br>
150
 
 
151
 
            Returns YES if all the document headers have been parsed but
152
 
            the document body parsing may not yet be complete.
153
 
          
154
 
 <hr>
155
 
<h3><a name ="method-7">isInHeaders</a></h3>
156
 
- (BOOL) <b>isInHeaders</b>;<br>
157
 
 
158
 
            Returns YES if parsing of the document headers has not yet
159
 
            been completed.
160
 
          
161
 
 <hr>
162
 
<h3><a name ="method-8">parse:</a></h3>
163
 
- (BOOL) <b>parse:</b> (NSData*)rawData;<br>
164
 
 
165
 
            <p>
166
 
 
167
 
              This method is called repeatedly to pass raw mime data into
168
 
              the parser.  It returns <code>YES</code> as long as it wants
169
 
              more data to complete parsing of a document, and <code>NO</code>
170
 
              if parsing is complete, either due to having reached the end of
171
 
              a document or due to an error.
172
 
            </p>
173
 
 
174
 
            <p>
175
 
 
176
 
              Since it is not always possible to determine if the end of a
177
 
              MIME document has been reached from its content, the method
178
 
              may need to be called with a nil argument after you have
179
 
              passed all the data to it ... this tells it that the data
180
 
              is complete.
181
 
            </p>
182
 
 
183
 
          
184
 
 <hr>
185
 
<h3><a name ="method-9">parseHeader:</a></h3>
186
 
- (BOOL) <b>parseHeader:</b> (NSString*)aRawHeader;<br>
187
 
 
188
 
            <p>
189
 
 
190
 
              This method is called to parse a header line <em>for the
191
 
              current document</em>, split its contents into an info
192
 
              dictionary, and add that information to the document.
193
 
            </p>
194
 
 
195
 
            <p>
196
 
 
197
 
              The standard implementation of this method scans basic
198
 
              information and then calls <code>scanHeaders:named:into:</code>
199
 
              to complete the parsing of the header.
200
 
            </p>
201
 
 
202
 
            <p>
203
 
 
204
 
              This method also performs consistency checks on headers scanned
205
 
              so it is recommended that it is not overridden, but that
206
 
              subclasses override <code>scanHeaders:named:into:</code> to
207
 
              implement custom scanning.
208
 
            </p>
209
 
 
210
 
            <p>
211
 
 
212
 
              As a special case, for HTTP support, this method also parses
213
 
              lines in the format of HTTP responses as if they were headers
214
 
              named <code>http</code>.  The resulting header info dictionary
215
 
              contains -
216
 
            </p>
217
 
 
218
 
            <dl>
219
 
<dt>HttpMajorVersion
220
 
<dd>The first part of the version number
221
 
<dt>HttpMinorVersion
222
 
<dd>The second part of the version number
223
 
<dt>NSHTTPPropertyServerHTTPVersionKey
224
 
<dd>The full HTTP protocol version number
225
 
<dt>NSHTTPPropertyStatusCodeKey
226
 
<dd>The HTTP status code
227
 
<dt>NSHTTPPropertyStatusReasonKey
228
 
<dd>The text message (if any) after the status code
229
 
</dl>
230
 
 
231
 
          
232
 
 <hr>
233
 
<h3><a name ="method-10">parsingHeaders</a></h3>
234
 
- (BOOL) <b>parsingHeaders</b>;<br>
235
 
 
236
 
            Returns YES if the parser is expecting to read mime headers,
237
 
            Returns NO is the parser has already been passed all the
238
 
            data containing headers, and is now waiting for the body of
239
 
            the mime message (or has been passed all data).
240
 
          
241
 
 <hr>
242
 
<h3><a name ="method-11">scanHeader:named:inTo:</a></h3>
243
 
- (BOOL) <b>scanHeader:</b> (NSScanner*)aScanner <b>named:</b> (NSString*)aName <b>inTo:</b> (NSMutableDictionary*)info;<br>
244
 
 
245
 
            <p>
246
 
 
247
 
              This method is called to parse a header line and split its
248
 
              contents into an info dictionary.
249
 
            </p>
250
 
 
251
 
            <p>
252
 
 
253
 
              On entry, the dictionary is already partially filled,
254
 
              the name argument is a lowercase representation of the
255
 
              header name, and the scanner is set to a scan location
256
 
              immediately after the colon in the header string.
257
 
            </p>
258
 
 
259
 
            <p>
260
 
 
261
 
              If the header is parsed successfully, the method should
262
 
              return YES, otherwise NO.
263
 
            </p>
264
 
 
265
 
            <p>
266
 
 
267
 
              You should not call this method directly yourself, but may
268
 
              override it to support parsing of new headers.
269
 
            </p>
270
 
 
271
 
            <p>
272
 
 
273
 
              You should be aware of the parsing that the standard
274
 
              implementation performs, and that <em>needs</em> to be
275
 
              done for certain headers in order to permit the parser to
276
 
              work generally -
277
 
            </p>
278
 
 
279
 
            <dl>
280
 
<dt>content-disposition
281
 
<dd>
282
 
                <dl>
283
 
<dt>Parameters
284
 
<dd>
285
 
                    A dictionary containing parameters as key-value pairs
286
 
                    in lowercase
287
 
                  
288
 
<dt>Value
289
 
<dd>
290
 
                    The content disposition (excluding parameters) as a
291
 
                    lowercase string.
292
 
                  
293
 
</dl>
294
 
 
295
 
              
296
 
<dt>content-type
297
 
<dd>
298
 
                <dl>
299
 
<dt>Parameters
300
 
<dd>
301
 
                    A dictionary containing parameters as key-value pairs
302
 
                    in lowercase.
303
 
                  
304
 
<dt>SubType
305
 
<dd>The MIME subtype lowercase
306
 
<dt>Type
307
 
<dd>The MIME type lowercase
308
 
<dt>value
309
 
<dd>The full MIME type (xxx/yyy) in lowercase
310
 
</dl>
311
 
 
312
 
              
313
 
<dt>content-transfer-encoding
314
 
<dd>
315
 
                <dl>
316
 
<dt>Value
317
 
<dd>The transfer encoding type in lowercase
318
 
</dl>
319
 
 
320
 
              
321
 
<dt>http
322
 
<dd>
323
 
                <dl>
324
 
<dt>HttpVersion
325
 
<dd>The HTTP protocol version number
326
 
<dt>HttpMajorVersion
327
 
<dd>The first component of the version number
328
 
<dt>HttpMinorVersion
329
 
<dd>The second component of the version number
330
 
<dt>HttpStatus
331
 
<dd>The response status value (numeric code)
332
 
<dt>Value
333
 
<dd>The text message (if any)
334
 
</dl>
335
 
 
336
 
              
337
 
<dt>transfer-encoding
338
 
<dd>
339
 
                <dl>
340
 
<dt>Value
341
 
<dd>The transfer encoding type in lowercase
342
 
</dl>
343
 
 
344
 
              
345
 
</dl>
346
 
 
347
 
          
348
 
 <hr>
349
 
<h3><a name ="method-12">scanSpace:</a></h3>
350
 
- (BOOL) <b>scanSpace:</b> (NSScanner*)aScanner;<br>
351
 
 
352
 
            A convenience method to scan past any whitespace in the scanner
353
 
            in preparation for scanning something more interesting that
354
 
            comes after it.  Returns YES if any space was read, NO otherwise.
355
 
          
356
 
 <hr>
357
 
<h3><a name ="method-13">scanSpecial:</a></h3>
358
 
- (NSString*) <b>scanSpecial:</b> (NSScanner*)aScanner;<br>
359
 
 
360
 
            A convenience method to use a scanner (that is set up to scan a
361
 
            header line) to scan in a special character that terminated a
362
 
            token previously scanned.  If the token was terminated by
363
 
            whitespace and no other special character, the string returned
364
 
            will contain a single space character.
365
 
          
366
 
 <hr>
367
 
<h3><a name ="method-14">scanToken:</a></h3>
368
 
- (NSString*) <b>scanToken:</b> (NSScanner*)aScanner;<br>
369
 
 
370
 
            A convenience method to use a scanner (that is set up to scan a
371
 
            header line) to scan a header token - either a quoted string or
372
 
            a simple word.
373
 
            <ul>
374
 
<li >Leading whitespace is ignored.
375
 
<li >Backslash escapes in quoted text are converted
376
 
</ul>
377
 
 
378
 
          
379
 
 <hr>
380
 
</body>
381
 
 
382
 
 </html>