~ubuntu-branches/ubuntu/lucid/curl/lucid-201101212007

« back to all changes in this revision

Viewing changes to lib/http_chunks.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-02-08 11:20:41 UTC
  • mto: (3.1.1 lenny) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080208112041-hed7sb5r6ghmjf8v
Tags: upstream-7.18.0
ImportĀ upstreamĀ versionĀ 7.18.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: http_chunks.c,v 1.38 2007-10-02 10:21:36 bagder Exp $
 
21
 * $Id: http_chunks.c,v 1.42 2008-01-02 22:30:34 bagder Exp $
22
22
 ***************************************************************************/
23
23
#include "setup.h"
24
24
 
109
109
  CURLcode result=CURLE_OK;
110
110
  struct SessionHandle *data = conn->data;
111
111
  struct Curl_chunker *ch = &conn->chunk;
112
 
  struct Curl_transfer_keeper *k = &data->reqdata.keep;
 
112
  struct SingleRequest *k = &data->req;
113
113
  size_t piece;
114
114
  size_t length = (size_t)datalen;
115
115
  size_t *wrote = (size_t *)wrotep;
118
118
 
119
119
  /* the original data is written to the client, but we go on with the
120
120
     chunk read process, to properly calculate the content length*/
121
 
  if (data->set.http_te_skip && !k->ignorebody)
122
 
    Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
 
121
  if(data->set.http_te_skip && !k->ignorebody) {
 
122
    result = Curl_client_write(conn, CLIENTWRITE_BODY, datap, datalen);
 
123
    if(result)
 
124
      return CHUNKE_WRITE_ERROR;
 
125
  }
123
126
 
124
127
  while(length) {
125
128
    switch(ch->state) {
178
181
      if(*datap == 0x0a) {
179
182
        /* we're now expecting data to come, unless size was zero! */
180
183
        if(0 == ch->datasize) {
181
 
          if (conn->bits.trailerHdrPresent!=TRUE) {
 
184
          if(conn->bits.trailerhdrpresent!=TRUE) {
182
185
            /* No Trailer: header found - revert to original Curl processing */
183
186
            ch->state = CHUNK_STOPCR;
184
187
 
217
220
      /* Write the data portion available */
218
221
#ifdef HAVE_LIBZ
219
222
      switch (conn->data->set.http_ce_skip?
220
 
              IDENTITY : data->reqdata.keep.content_encoding) {
 
223
              IDENTITY : data->req.content_encoding) {
221
224
      case IDENTITY:
222
225
#endif
223
226
        if(!k->ignorebody) {
224
 
          if ( !data->set.http_te_skip )
 
227
          if( !data->set.http_te_skip )
225
228
            result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
226
229
                                       piece);
227
230
          else
231
234
        break;
232
235
 
233
236
      case DEFLATE:
234
 
        /* update data->reqdata.keep.str to point to the chunk data. */
235
 
        data->reqdata.keep.str = datap;
236
 
        result = Curl_unencode_deflate_write(conn, &data->reqdata.keep,
 
237
        /* update data->req.keep.str to point to the chunk data. */
 
238
        data->req.str = datap;
 
239
        result = Curl_unencode_deflate_write(conn, &data->req,
237
240
                                             (ssize_t)piece);
238
241
        break;
239
242
 
240
243
      case GZIP:
241
 
        /* update data->reqdata.keep.str to point to the chunk data. */
242
 
        data->reqdata.keep.str = datap;
243
 
        result = Curl_unencode_gzip_write(conn, &data->reqdata.keep,
 
244
        /* update data->req.keep.str to point to the chunk data. */
 
245
        data->req.str = datap;
 
246
        result = Curl_unencode_gzip_write(conn, &data->req,
244
247
                                          (ssize_t)piece);
245
248
        break;
246
249
 
298
301
    case CHUNK_TRAILER:
299
302
      /* conn->trailer is assumed to be freed in url.c on a
300
303
         connection basis */
301
 
      if (conn->trlPos >= conn->trlMax) {
 
304
      if(conn->trlPos >= conn->trlMax) {
302
305
        char *ptr;
303
306
        if(conn->trlMax) {
304
307
          conn->trlMax *= 2;
333
336
      break;
334
337
 
335
338
    case CHUNK_TRAILER_POSTCR:
336
 
      if (*datap == 0x0a) {
 
339
      if(*datap == 0x0a) {
337
340
        conn->trailer[conn->trlPos++]=0x0a;
338
341
        conn->trailer[conn->trlPos]=0;
339
 
        if (conn->trlPos==2) {
 
342
        if(conn->trlPos==2) {
340
343
          ch->state = CHUNK_STOP;
341
344
          datap++;
342
345
          length--;
362
365
            return(CHUNKE_BAD_CHUNK);
363
366
          }
364
367
#endif /* CURL_DOES_CONVERSIONS */
365
 
          if ( !data->set.http_te_skip )
366
 
            Curl_client_write(conn, CLIENTWRITE_HEADER,
367
 
                              conn->trailer, conn->trlPos);
 
368
          if(!data->set.http_te_skip) {
 
369
            result = Curl_client_write(conn, CLIENTWRITE_HEADER,
 
370
                                       conn->trailer, conn->trlPos);
 
371
            if(result)
 
372
              return CHUNKE_WRITE_ERROR;
 
373
          }
368
374
        }
369
375
        ch->state = CHUNK_TRAILER;
370
376
        conn->trlPos=0;
389
395
      break;
390
396
 
391
397
    case CHUNK_STOP:
392
 
      if (*datap == 0x0a) {
 
398
      if(*datap == 0x0a) {
393
399
        datap++;
394
400
        length--;
395
401