| 1135 | } |
| 1136 | |
| 1137 | static apr_status_t store_body(cache_handle_t *h, request_rec *r, |
| 1138 | apr_bucket_brigade *in, apr_bucket_brigade *out) |
| 1139 | { |
| 1140 | apr_bucket *e; |
| 1141 | apr_status_t rv = APR_SUCCESS; |
| 1142 | disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj; |
| 1143 | disk_cache_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &cache_disk_module); |
| 1144 | int seen_eos = 0; |
| 1145 | |
| 1146 | if (!dobj->offset) { |
| 1147 | dobj->offset = dconf->readsize; |
| 1148 | } |
| 1149 | if (!dobj->timeout && dconf->readtime) { |
| 1150 | dobj->timeout = apr_time_now() + dconf->readtime; |
| 1151 | } |
| 1152 | |
| 1153 | if (dobj->offset) { |
| 1154 | apr_brigade_partition(in, dobj->offset, &e); |
| 1155 | } |
| 1156 | |
| 1157 | while (APR_SUCCESS == rv && !APR_BRIGADE_EMPTY(in)) { |
| 1158 | const char *str; |
| 1159 | apr_size_t length, written; |
| 1160 | |
| 1161 | e = APR_BRIGADE_FIRST(in); |
| 1162 | |
| 1163 | /* are we done completely? if so, pass any trailing buckets right through */ |
| 1164 | if (dobj->done || !dobj->data.pool) { |
| 1165 | APR_BUCKET_REMOVE(e); |
| 1166 | APR_BRIGADE_INSERT_TAIL(out, e); |
| 1167 | continue; |
| 1168 | } |
| 1169 | |
| 1170 | /* have we seen eos yet? */ |
| 1171 | if (APR_BUCKET_IS_EOS(e)) { |
| 1172 | seen_eos = 1; |
| 1173 | dobj->done = 1; |
| 1174 | APR_BUCKET_REMOVE(e); |
| 1175 | APR_BRIGADE_INSERT_TAIL(out, e); |
| 1176 | break; |
| 1177 | } |
| 1178 | |
| 1179 | /* honour flush buckets, we'll get called again */ |
| 1180 | if (APR_BUCKET_IS_FLUSH(e)) { |
| 1181 | APR_BUCKET_REMOVE(e); |
| 1182 | APR_BRIGADE_INSERT_TAIL(out, e); |
| 1183 | break; |
| 1184 | } |
| 1185 | |
| 1186 | /* metadata buckets are preserved as is */ |
| 1187 | if (APR_BUCKET_IS_METADATA(e)) { |
| 1188 | APR_BUCKET_REMOVE(e); |
| 1189 | APR_BRIGADE_INSERT_TAIL(out, e); |
| 1190 | continue; |
| 1191 | } |
| 1192 | |
| 1193 | /* read the bucket, write to the cache */ |
| 1194 | rv = apr_bucket_read(e, &str, &length, APR_BLOCK_READ); |
nothing calls this directly
no test coverage detected