221 if (!pp || !pp->value) |
221 if (!pp || !pp->value) |
222 return REQ_ABORTED; |
222 return REQ_ABORTED; |
223 snprintf(pp->value, content_length_size, "%lld", (long long)size); |
223 snprintf(pp->value, content_length_size, "%lld", (long long)size); |
224 pblock_kpinsert(pb_key_content_length, pp, rq->srvhdrs); |
224 pblock_kpinsert(pb_key_content_length, pp, rq->srvhdrs); |
225 |
225 |
226 char *etag; |
|
227 if (http_etag) { |
226 if (http_etag) { |
228 /* Insert Etag */ |
227 /* Insert Etag */ |
229 pp = pblock_key_param_create(rq->srvhdrs, pb_key_etag, NULL, MAX_ETAG); |
228 if(etag) { |
230 if (!pp || !pp->value) |
229 pblock_kvinsert(pb_key_etag, etag, strlen(etag), rq->srvhdrs); |
231 return REQ_ABORTED; |
230 } else { |
232 http_format_etag(sn, rq, pp->value, MAX_ETAG, size, mtime); |
231 pp = pblock_key_param_create(rq->srvhdrs, pb_key_etag, NULL, MAX_ETAG); |
233 pblock_kpinsert(pb_key_etag, pp, rq->srvhdrs); |
232 if (!pp || !pp->value) |
234 etag = pp->value; |
233 return REQ_ABORTED; |
|
234 http_format_etag(sn, rq, pp->value, MAX_ETAG, size, mtime); |
|
235 pblock_kpinsert(pb_key_etag, pp, rq->srvhdrs); |
|
236 etag = pp->value; |
|
237 } |
|
238 |
235 } else { |
239 } else { |
236 etag = NULL; |
240 etag = NULL; |
237 } |
241 } |
238 |
242 |
239 /* Check If-modified-since, etc. */ |
243 /* Check If-modified-since, etc. */ |
240 return http_check_preconditions(sn, rq, mtm, etag); |
244 return http_check_preconditions(sn, rq, mtm, etag); |
241 } |
245 } |
242 |
246 |
243 NSAPI_PUBLIC int http_set_finfo(Session *sn, Request *rq, struct stat *finfo) |
247 NSAPI_PUBLIC int http_set_finfo(Session *sn, Request *rq, struct stat *finfo) |
244 { |
248 { |
245 return set_finfo(sn, rq, finfo->st_size, finfo->st_mtime); |
249 return set_finfo(sn, rq, finfo->st_size, finfo->st_mtime, NULL); |
|
250 } |
|
251 |
|
252 NSAPI_PUBLIC int http_set_finfo_etag(Session *sn, Request *rq, struct stat *finfo, const char *etag) { |
|
253 return set_finfo(sn, rq, finfo->st_size, finfo->st_mtime, etag); |
246 } |
254 } |
247 |
255 |
248 |
256 |
249 /* ---------------------------- http_hdrs2env ----------------------------- */ |
257 /* ---------------------------- http_hdrs2env ----------------------------- */ |
250 |
258 |