expcov report - Generated Sat Oct 15 21:39:18 2016

 Index  Statistics  Last 
Directory./modules/http
Filenamechunk_filter.c
ModifiedThu Dec 13 05:43:04 2007

Pass Half Fail Excluded Total
Function
0
0.00%
1
100.00%
0
0.00%
1
100%
Expressions
0
0.00%
62
100.00%
0
0.00%
62
100%
Conditions
0
0.00%
0
0.00%
15
100.00%
0
0.00%
15
100%
MC/DC
0
0.00%
5
100.00%
0
0.00%
5
100%
Branches

if
0
0.00%
0
0.00%
12
100.00%
0
0.00%
12
100%
for
0
0.00%
0
0.00%
2
100.00%
0
0.00%
2
100%
while
0
0.00%
0
0.00%
0
0.00%
0
0.00%
0
100%
case
0
0.00%
0
0.00%
0
0.00%
0
0.00%
0
100%

1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements.  See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License.  You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * chunk_filter.c --- HTTP/1.1 chunked transfer encoding filter.
19 */
20
21#include "apr_strings.h"
22#include "apr_thread_proc.h"    /* for RLIMIT stuff */
23
24#define APR_WANT_STRFUNC
25#include "apr_want.h"
26
27#define CORE_PRIVATE
28#include "httpd.h"
29#include "http_config.h"
30#include "http_connection.h"
31#include "http_core.h"
32#include "http_protocol.h"  /* For index_of_response().  Grump. */
33#include "http_request.h"
34
35#include "util_filter.h"
36#include "util_ebcdic.h"
37#include "ap_mpm.h"
38#include "scoreboard.h"
39
40#include "mod_core.h"
41
42/*
43 * A pointer to this is used to memorize in the filter context that a bad
44 * gateway error bucket had been seen. It is used as an invented unique pointer.
45 */
46static char bad_gateway_seen;
47
48apr_status_t ap_http_chunk_filter : call=0
a
p_http_chunk_filter(ap_filter_t *f, apr_bucket_brigade *b)
49{
50#define ASCII_CRLF  "\015\012"
51#define ASCII_ZERO  "\060"
52    conn_rec *c = f : modules/http/chunk_filter.c line=48 column=48
f
-> : enter=0, leave=0
-
>r : include/util_filter.h line=277 column=18
r
-> : enter=0, leave=0
-
>connection : include/httpd.h line=782 column=15
c
onnection;
53    apr_bucket_brigade *more;
54    apr_bucket *e;
55    apr_status_t rv;
56
57    for : true=0, false=0
f
or (more : modules/http/chunk_filter.c line=53 column=25
m
ore = : pass=0
=
 NULL; b : modules/http/chunk_filter.c line=48 column=71
b
b : modules/http/chunk_filter.c line=48 column=71
b
 = : pass=0
=
 more : modules/http/chunk_filter.c line=53 column=25
m
ore, more : modules/http/chunk_filter.c line=53 column=25
m
ore = : pass=0
=
 NULL) {
58        apr_off_t bytes = 0;
59        apr_bucket *eos = NULL;
60        apr_bucket *flush = NULL;
61        /* XXX: chunk_hdr must remain at this scope since it is used in a
62         *      transient bucket.
63         */
64        char chunk_hdr[20]; /* enough space for the snprintf below */
65
66
67        for : true=0, false=0
f
or (e : modules/http/chunk_filter.c line=54 column=17
e
 = : pass=0
=
 APR_BRIGADE_FIRST(b : modules/http/chunk_filter.c line=48 column=71
b
);
68             e : modules/http/chunk_filter.c line=54 column=17
e
 != : true=0, false=0
!
= APR_BRIGADE_SENTINEL(b : modules/http/chunk_filter.c line=48 column=71
b
);
69             e : modules/http/chunk_filter.c line=54 column=17
e
 = : pass=0
=
 APR_BUCKET_NEXT(e : modules/http/chunk_filter.c line=54 column=17
e
))
70        {
71            if : true=0, false=0
i
f (APR_BUCKET_IS_EOS(e : modules/http/chunk_filter.c line=54 column=17
e
)) {
72                /* there shouldn't be anything after the eos */
73                eos : modules/http/chunk_filter.c line=59 column=21
e
os = : pass=0
=
 e : modules/http/chunk_filter.c line=54 column=17
e
;
74                break : pass=0
b
reak;
75            }
76            if : true=0, false=0
i
f (AP_BUCKET_IS_ERROR(e : modules/http/chunk_filter.c line=54 column=17
e
)
77                && : true=0, false=0
&
& (((ap_bucket_error *)(e : modules/http/chunk_filter.c line=54 column=17
e
-> : enter=0, leave=0
-
>data : /usr/include/apr-1/apr_buckets.h line=244 column=11 data))-> : enter=0, leave=0
-
>status : include/http_protocol.h line=634 column=9
s
tatus
78                    == : true=0, false=0
MC/DC independently affect : true=0, false=0
=TF
= HTTP_BAD_GATEWAY)) {
79                /*
80                 * We had a broken backend. Memorize this in the filter
81                 * context.
82                 */
83                f : modules/http/chunk_filter.c line=48 column=48
f
-> : enter=0, leave=0
-
>ctx : include/util_filter.h line=268 column=11
c
tx = : enter=0, leave=0
=
 &bad_gateway_seen : modules/http/chunk_filter.c line=46 column=13
b
ad_gateway_seen;
84                continue : pass=0
c
ontinue;
85            }
86            if : true=0, false=0
i
f (APR_BUCKET_IS_FLUSH(e : modules/http/chunk_filter.c line=54 column=17
e
)) {
87                flush : modules/http/chunk_filter.c line=60 column=21
f
lush = : pass=0
=
 e : modules/http/chunk_filter.c line=54 column=17
e
;
88                if : true=0, false=0
i
f (e : modules/http/chunk_filter.c line=54 column=17
e
 != : true=0, false=0
!
= APR_BRIGADE_LAST(b : modules/http/chunk_filter.c line=48 column=71
b
)) {
89                    more : modules/http/chunk_filter.c line=53 column=25
m
ore = : pass=0
=
 apr_brigade_split : enter=0, leave=0

apr_brigade_split : /usr/include/apr-1/apr_buckets.h line=709 column=35
a
pr_brigade_split(b : modules/http/chunk_filter.c line=48 column=71
b
, APR_BUCKET_NEXT(e : modules/http/chunk_filter.c line=54 column=17
e
));
90                }
91                break : pass=0
b
reak;
92            }
93            else if : true=0, false=0
i
f (e : modules/http/chunk_filter.c line=54 column=17
e
-> : enter=0, leave=0
-
>length : /usr/include/apr-1/apr_buckets.h line=234 column=16 length == : true=0, false=0
=
= (apr_size_t)-1) {
94                /* unknown amount of data (e.g. a pipe) */
95                const char *data;
96                apr_size_t len;
97
98                rv : modules/http/chunk_filter.c line=55 column=18
r
= : pass=0
=
 apr_bucket_read(e : modules/http/chunk_filter.c line=54 column=17
e
, &data : modules/http/chunk_filter.c line=95 column=29
d
ata, &len : modules/http/chunk_filter.c line=96 column=28
l
en, APR_BLOCK_READ : /usr/include/apr-1/apr_buckets.h line=58 column=5 APR_BLOCK_READ);
99                if : true=0, false=0
i
f (rv : modules/http/chunk_filter.c line=55 column=18
r
!= : true=0, false=0
!
= APR_SUCCESS) {
100                    return : pass=0
r
eturn rv : modules/http/chunk_filter.c line=55 column=18
r
v;
101                }
102                if : true=0, false=0
i
f (len : modules/http/chunk_filter.c line=96 column=28
l
en > : true=0, false=0
>
 0) {
103                    /*
104                     * There may be a new next bucket representing the
105                     * rest of the data stream on which a read() may
106                     * block so we pass down what we have so far.
107                     */
108                    bytes : modules/http/chunk_filter.c line=58 column=19
b
ytes += : pass=0
+
len : modules/http/chunk_filter.c line=96 column=28
l
en;
109                    more : modules/http/chunk_filter.c line=53 column=25
m
ore = : pass=0
=
 apr_brigade_split : enter=0, leave=0

apr_brigade_split : /usr/include/apr-1/apr_buckets.h line=709 column=35
a
pr_brigade_split(b : modules/http/chunk_filter.c line=48 column=71
b
, APR_BUCKET_NEXT(e : modules/http/chunk_filter.c line=54 column=17
e
));
110                    break : pass=0
b
reak;
111                }
112                else {
113                    /* If there was nothing in this bucket then we can
114                     * safely move on to the next one without pausing
115                     * to pass down what we have counted up so far.
116                     */
117                    continue : pass=0
c
ontinue;
118                }
119            }
120            else {
121                bytes : modules/http/chunk_filter.c line=58 column=19
b
ytes += : pass=0
+
e : modules/http/chunk_filter.c line=54 column=17
e
-> : enter=0, leave=0
-
>length : /usr/include/apr-1/apr_buckets.h line=234 column=16 length;
122            }
123        }
124
125        /*
126         * XXX: if there aren't very many bytes at this point it may
127         * be a good idea to set them aside and return for more,
128         * unless we haven't finished counting this brigade yet.
129         */
130        /* if there are content bytes, then wrap them in a chunk */
131        if : true=0, false=0
i
f (bytes : modules/http/chunk_filter.c line=58 column=19
b
ytes > : true=0, false=0
>
 0) {
132            apr_size_t hdr_len;
133            /*
134             * Insert the chunk header, specifying the number of bytes in
135             * the chunk.
136             */
137            hdr_len : modules/http/chunk_filter.c line=132 column=24
h
dr_len = : pass=0
=
 apr_snprintf : enter=0, leave=0

apr_snprintf : /usr/include/apr-1/apr_strings.h line=261 column=25
a
pr_snprintf(chunk_hdr : modules/http/chunk_filter.c line=64 column=14
c
hunk_hdr, sizeof(chunk_hdr),
138                                   "%" APR_UINT64_T_HEX_FMT CRLF, (apr_uint64_t)bytes : modules/http/chunk_filter.c line=58 column=19
b
ytes);
139            ap_xlate_proto_to_ascii(chunk_hdr, hdr_len);
140            e : modules/http/chunk_filter.c line=54 column=17
e
 = : pass=0
=
 apr_bucket_transient_create : enter=0, leave=0

apr_bucket_transient_create : /usr/include/apr-1/apr_buckets.h line=1318 column=27
a
pr_bucket_transient_create(chunk_hdr : modules/http/chunk_filter.c line=64 column=14
c
hunk_hdr, hdr_len : modules/http/chunk_filter.c line=132 column=24
h
dr_len,
141                                            c : modules/http/chunk_filter.c line=52 column=15
c
-> : enter=0, leave=0
-
>bucket_alloc : include/httpd.h line=1103 column=32
b
ucket_alloc);
142            APR_BRIGADE_INSERT_HEAD(b : modules/http/chunk_filter.c line=48 column=71
b
e : modules/http/chunk_filter.c line=54 column=17
e
);
143
144            /*
145             * Insert the end-of-chunk CRLF before an EOS or
146             * FLUSH bucket, or appended to the brigade
147             */
148            e : modules/http/chunk_filter.c line=54 column=17
e
 = : pass=0
=
 apr_bucket_immortal_create : enter=0, leave=0

apr_bucket_immortal_create : /usr/include/apr-1/apr_buckets.h line=1296 column=27
a
pr_bucket_immortal_create(ASCII_CRLF, 2, c : modules/http/chunk_filter.c line=52 column=15
c
-> : enter=0, leave=0
-
>bucket_alloc : include/httpd.h line=1103 column=32
b
ucket_alloc);
149            if : true=0, false=0
i
f (eos : modules/http/chunk_filter.c line=59 column=21
e
os != : true=0, false=0
!
= NULL) {
150                APR_BUCKET_INSERT_BEFORE(eos : modules/http/chunk_filter.c line=59 column=21
e
os, e : modules/http/chunk_filter.c line=54 column=17
e
);
151            }
152            else if : true=0, false=0
i
f (flush : modules/http/chunk_filter.c line=60 column=21
f
lush != : true=0, false=0
!
= NULL) {
153                APR_BUCKET_INSERT_BEFORE(flush : modules/http/chunk_filter.c line=60 column=21
f
lush, e : modules/http/chunk_filter.c line=54 column=17
e
);
154            }
155            else {
156                APR_BRIGADE_INSERT_TAIL(b : modules/http/chunk_filter.c line=48 column=71
b
e : modules/http/chunk_filter.c line=54 column=17
e
);
157            }
158        }
159
160        /* RFC 2616, Section 3.6.1
161         *
162         * If there is an EOS bucket, then prefix it with:
163         *   1) the last-chunk marker ("0" CRLF)
164         *   2) the trailer
165         *   3) the end-of-chunked body CRLF
166         *
167         * We only do this if we have not seen an error bucket with
168         * status HTTP_BAD_GATEWAY. We have memorized an
169         * error bucket that we had seen in the filter context.
170         * The error bucket with status HTTP_BAD_GATEWAY indicates that the
171         * connection to the backend (mod_proxy) broke in the middle of the
172         * response. In order to signal the client that something went wrong
173         * we do not create the last-chunk marker and set c->keepalive to
174         * AP_CONN_CLOSE in the core output filter.
175         *
176         * XXX: it would be nice to combine this with the end-of-chunk
177         * marker above, but this is a bit more straight-forward for
178         * now.
179         */
180        if : true=0, false=0
i
f (MC/DC independently affect : true=0, false=0

eos : modules/http/chunk_filter.c line=59 column=21
eTF
os && : true=0, false=0
&
! : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
f : modules/http/chunk_filter.c line=48 column=48
f
-> : enter=0, leave=0
-
>ctx : include/util_filter.h line=268 column=11
c
tx) {
181            /* XXX: (2) trailers ... does not yet exist */
182            e : modules/http/chunk_filter.c line=54 column=17
e
 = : pass=0
=
 apr_bucket_immortal_create : enter=0, leave=0

apr_bucket_immortal_create : /usr/include/apr-1/apr_buckets.h line=1296 column=27
a
pr_bucket_immortal_create(ASCII_ZERO ASCII_CRLF
183                                           /* <trailers> */
184                                           ASCII_CRLF, 5, c : modules/http/chunk_filter.c line=52 column=15
c
-> : enter=0, leave=0
-
>bucket_alloc : include/httpd.h line=1103 column=32
b
ucket_alloc);
185            APR_BUCKET_INSERT_BEFORE(eos : modules/http/chunk_filter.c line=59 column=21
e
os, e : modules/http/chunk_filter.c line=54 column=17
e
);
186        }
187
188        /* pass the brigade to the next filter. */
189        rv : modules/http/chunk_filter.c line=55 column=18
r
= : pass=0
=
 ap_pass_brigade : enter=0, leave=0

ap_pass_brigade : include/util_filter.h line=312 column=26
a
p_pass_brigade(f : modules/http/chunk_filter.c line=48 column=48
f
-> : enter=0, leave=0
-
>next : include/util_filter.h line=271 column=18
n
ext, b : modules/http/chunk_filter.c line=48 column=71
b
);
190        if : true=0, false=0
i
f (rv : modules/http/chunk_filter.c line=55 column=18
r
!= : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
= APR_SUCCESS || : true=0, false=0
|
eos : modules/http/chunk_filter.c line=59 column=21
e
os != : true=0, false=0
MC/DC independently affect : true=0, false=0
!TF
= NULL) {
191            return : pass=0
r
eturn rv : modules/http/chunk_filter.c line=55 column=18
r
v;
192        }
193    }
194    return : pass=0
r
eturn APR_SUCCESS;
195}
196[EOF]


Generated by expcov