b = http->buffer;
if (b == NULL) {
- size = njs_chb_size(&http->chain);
- if (size < 0) {
- ngx_js_http_error(http, "memory error");
- return;
- }
-
- b = ngx_create_temp_buf(http->pool, size);
+ b = ngx_js_chain_to_buf(http->pool, &http->chain);
if (b == NULL) {
ngx_js_http_error(http, "memory error");
return;
}
- njs_chb_join_to(&http->chain, b->last);
- b->last += size;
-
http->buffer = b;
}
}
+ngx_buf_t *
+ngx_js_chain_to_buf(ngx_pool_t *pool, njs_chb_t *chain)
+{
+ ssize_t size;
+ ngx_buf_t *buf;
+
+ size = njs_chb_size(chain);
+ if (size < 0) {
+ return NULL;
+ }
+
+ buf = ngx_create_temp_buf(pool, size);
+ if (buf == NULL) {
+ return NULL;
+ }
+
+ njs_chb_join_to(chain, buf->last);
+ buf->last += size;
+
+ return buf;
+}
+
+
static void
ngx_js_fetch_append_request_headers(njs_chb_t *chain,
ngx_js_request_t *request)
int trim_c0_control_or_space);
ngx_int_t ngx_js_check_header_name(u_char *name, size_t len);
+ngx_buf_t *ngx_js_chain_to_buf(ngx_pool_t *pool, njs_chb_t *chain);
+
void ngx_js_fetch_build_request(ngx_js_http_t *http, ngx_js_request_t *request,
ngx_str_t *path, ngx_url_t *u);