Deleted Added
sdiff udiff text old ( 256281 ) new ( 262339 )
full compact
1/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *

--- 29 unchanged lines hidden (view full) ---

38 serf_linebuf_t linebuf;
39
40 serf_status_line sl;
41
42 int chunked; /* Do we need to read trailers? */
43 int head_req; /* Was this a HEAD request? */
44} response_context_t;
45
46
47serf_bucket_t *serf_bucket_response_create(
48 serf_bucket_t *stream,
49 serf_bucket_alloc_t *allocator)
50{
51 response_context_t *ctx;
52
53 ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx));
54 ctx->stream = stream;

--- 178 unchanged lines hidden (view full) ---

233 * Move on to the body.
234 */
235 if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) {
236 const void *v;
237
238 /* Advance the state. */
239 ctx->state = STATE_BODY;
240
241 ctx->body =
242 serf_bucket_barrier_create(ctx->stream, bkt->allocator);
243
244 /* Are we C-L, chunked, or conn close? */
245 v = serf_bucket_headers_get(ctx->headers, "Content-Length");
246 if (v) {
247 apr_uint64_t length;
248 length = apr_strtoi64(v, NULL, 10);

--- 7 unchanged lines hidden (view full) ---

256 v = serf_bucket_headers_get(ctx->headers, "Transfer-Encoding");
257
258 /* Need to handle multiple transfer-encoding. */
259 if (v && strcasecmp("chunked", v) == 0) {
260 ctx->chunked = 1;
261 ctx->body = serf_bucket_dechunk_create(ctx->body,
262 bkt->allocator);
263 }
264
265 if (!v && (ctx->sl.code == 204 || ctx->sl.code == 304)) {
266 ctx->state = STATE_DONE;
267 }
268 }
269 v = serf_bucket_headers_get(ctx->headers, "Content-Encoding");
270 if (v) {
271 /* Need to handle multiple content-encoding. */
272 if (v && strcasecmp("gzip", v) == 0) {
273 ctx->body =
274 serf_bucket_deflate_create(ctx->body, bkt->allocator,
275 SERF_DEFLATE_GZIP);
276 }
277 else if (v && strcasecmp("deflate", v) == 0) {
278 ctx->body =
279 serf_bucket_deflate_create(ctx->body, bkt->allocator,
280 SERF_DEFLATE_DEFLATE);
281 }
282 }
283 /* If we're a HEAD request, we don't receive a body. */
284 if (ctx->head_req) {
285 ctx->state = STATE_DONE;
286 }
287 }
288 break;
289 case STATE_BODY:
290 /* Don't do anything. */
291 break;
292 case STATE_TRAILERS:
293 status = fetch_headers(bkt, ctx);
294 if (SERF_BUCKET_READ_ERROR(status))

--- 170 unchanged lines hidden ---