Lines Matching refs:b
334 cpv->v.u = (unsigned int)gw_get_defaults_balance(srv, cpv->v.b); in SETDEFAULTS_FUNC()
389 static const buffer * http_header_remap_host_match (buffer *b, size_t off, http_header_remap_opts *… in http_header_remap_host_match() argument
395 const char * const s = b->ptr+off; in http_header_remap_host_match()
430 static size_t http_header_remap_host (buffer *b, size_t off, http_header_remap_opts *remap_hdrs, in… in http_header_remap_host() argument
433 http_header_remap_host_match(b, off, remap_hdrs, is_req, alen); in http_header_remap_host()
436 buffer_substr_replace(b, off, alen, m); in http_header_remap_host()
442 static size_t http_header_remap_urlpath (buffer *b, size_t off, http_header_remap_opts *remap_hdrs,… in http_header_remap_urlpath() argument
446 const char * const s = b->ptr+off; in http_header_remap_urlpath()
447 const size_t plen = buffer_clen(b) - off; /*(urlpath len)*/ in http_header_remap_urlpath()
455 buffer_substr_replace(b, off, mlen, &ds->value); in http_header_remap_urlpath()
465 buffer_substr_replace(b, off, mlen, &ds->key); in http_header_remap_urlpath()
473 buffer_substr_replace(b, off, mlen, &ds->key); in http_header_remap_urlpath()
484 static void http_header_remap_uri (buffer *b, size_t off, http_header_remap_opts *remap_hdrs, int i… in http_header_remap_uri() argument
488 if (b->ptr[off] != '/') { in http_header_remap_uri()
489 char *s = b->ptr+off; in http_header_remap_uri()
496 slen = s - (b->ptr+off); in http_header_remap_uri()
498 off = (size_t)(s - b->ptr); in http_header_remap_uri()
500 alen = (size_t)(s - b->ptr) - off; in http_header_remap_uri()
504 alen = buffer_clen(b) - off; in http_header_remap_uri()
506 buffer_append_char(b, '/'); in http_header_remap_uri()
510 m = http_header_remap_host_match(b, off, remap_hdrs, is_req, alen); in http_header_remap_uri()
513 && (is_req ? 5==slen && 0==memcmp(b->ptr+off-slen-3,"https",5) in http_header_remap_uri()
514 : 4==slen && 0==memcmp(b->ptr+off-slen-3,"http",4))){ in http_header_remap_uri()
516 memcpy(b->ptr+off-slen-3+4,"://",3); /*("https"=>"http")*/ in http_header_remap_uri()
521 memcpy(b->ptr+off-slen-3+4,"s://",4); /*("http" =>"https")*/ in http_header_remap_uri()
526 buffer_substr_replace(b, off, alen, m); in http_header_remap_uri()
533 http_header_remap_urlpath(b, off, remap_hdrs, is_req); in http_header_remap_uri()
538 static void http_header_remap_setcookie (buffer *b, size_t off, http_header_remap_opts *remap_hdrs) in http_header_remap_setcookie() argument
545 for (char *s = b->ptr+off, *e; *s; s = e) { in http_header_remap_setcookie()
567 off = (size_t)(e - b->ptr); in http_header_remap_setcookie()
568 len = http_header_remap_urlpath(b, off, remap_hdrs, 0); in http_header_remap_setcookie()
569 e = b->ptr+off+len; /*(b may have been reallocated)*/ in http_header_remap_setcookie()
579 off = (size_t)(e - b->ptr); in http_header_remap_setcookie()
582 len = http_header_remap_host(b, off, remap_hdrs, 0, alen); in http_header_remap_setcookie()
583 e = b->ptr+off+len; /*(b may have been reallocated)*/ in http_header_remap_setcookie()
595 static void buffer_append_string_backslash_escaped(buffer *b, const char *s, size_t len) { in buffer_append_string_backslash_escaped() argument
598 char * const p = buffer_string_prepare_append(b, len*2 + 4); in buffer_append_string_backslash_escaped()
607 buffer_commit(b, j); in buffer_append_string_backslash_escaped()
611 buffer *b = NULL; in proxy_set_Forwarded() local
620 b = http_header_request_get(r, HTTP_HEADER_FORWARDED, CONST_STR_LEN("Forwarded")); in proxy_set_Forwarded()
622 if (flags && NULL == b) { in proxy_set_Forwarded()
625 b = http_header_request_set_ptr(r, HTTP_HEADER_FORWARDED, in proxy_set_Forwarded()
644 ? buffer_append_string_len(b, CONST_STR_LEN("for=\"[")) in proxy_set_Forwarded()
645 : buffer_append_string_len(b, CONST_STR_LEN("for=\"")); in proxy_set_Forwarded()
646 buffer_append_string_backslash_escaped(b, s+j, i-j); in proxy_set_Forwarded()
648 ? buffer_append_string_len(b, CONST_STR_LEN("]\", ")) in proxy_set_Forwarded()
649 : buffer_append_string_len(b, CONST_STR_LEN("\", ")); in proxy_set_Forwarded()
653 buffer_append_string_len(b, CONST_STR_LEN(", ")); in proxy_set_Forwarded()
658 buffer_append_string_len(b, CONST_STR_LEN("for=")); in proxy_set_Forwarded()
668 ? buffer_append_string_len(b, CONST_STR_LEN("\"[")) in proxy_set_Forwarded()
669 : buffer_append_char(b, '"'); in proxy_set_Forwarded()
670 buffer_append_string_backslash_escaped(b, BUF_PTR_LEN(efor)); in proxy_set_Forwarded()
672 ? buffer_append_string_len(b, CONST_STR_LEN("]\"")) in proxy_set_Forwarded()
673 : buffer_append_char(b, '"'); in proxy_set_Forwarded()
677 buffer_append_string_buffer(b, &con->dst_addr_buf); in proxy_set_Forwarded()
679 buffer_append_str3(b, CONST_STR_LEN("\"["), in proxy_set_Forwarded()
683 buffer_append_char(b, '"'); in proxy_set_Forwarded()
685 b, BUF_PTR_LEN(&con->dst_addr_buf)); in proxy_set_Forwarded()
686 buffer_append_char(b, '"'); in proxy_set_Forwarded()
699 if (semicolon) buffer_append_char(b, ';'); in proxy_set_Forwarded()
700 buffer_append_string_len(b, CONST_STR_LEN("by=\"")); in proxy_set_Forwarded()
705 b, BUF_PTR_LEN(con->srv_socket->srv_token)); in proxy_set_Forwarded()
713 sock_addr_stringify_append_buffer(b, &addr); in proxy_set_Forwarded()
716 buffer_append_char(b, '"'); in proxy_set_Forwarded()
726 if (semicolon) buffer_append_char(b, ';'); in proxy_set_Forwarded()
728 buffer_append_str2(b, CONST_STR_LEN("proto="), BUF_PTR_LEN(eproto)); in proxy_set_Forwarded()
730 buffer_append_string_len(b, CONST_STR_LEN("proto=https")); in proxy_set_Forwarded()
732 buffer_append_string_len(b, CONST_STR_LEN("proto=http")); in proxy_set_Forwarded()
743 buffer_append_char(b, ';'); in proxy_set_Forwarded()
744 buffer_append_string_len(b, CONST_STR_LEN("host=\"")); in proxy_set_Forwarded()
746 b, BUF_PTR_LEN(ehost)); in proxy_set_Forwarded()
747 buffer_append_char(b, '"'); in proxy_set_Forwarded()
751 buffer_append_char(b, ';'); in proxy_set_Forwarded()
752 buffer_append_string_len(b, CONST_STR_LEN("host=\"")); in proxy_set_Forwarded()
754 b, BUF_PTR_LEN(r->http_host)); in proxy_set_Forwarded()
755 buffer_append_char(b, '"'); in proxy_set_Forwarded()
765 buffer_append_char(b, ';'); in proxy_set_Forwarded()
766 buffer_append_string_len(b, CONST_STR_LEN("remote_user=\"")); in proxy_set_Forwarded()
768 b, BUF_PTR_LEN(remote_user)); in proxy_set_Forwarded()
769 buffer_append_char(b, '"'); in proxy_set_Forwarded()
776 b = (NULL != efor) ? efor : &con->dst_addr_buf; in proxy_set_Forwarded()
779 BUF_PTR_LEN(b)); in proxy_set_Forwarded()
781 b = r->http_host; in proxy_set_Forwarded()
782 if (b && !buffer_is_blank(b)) { in proxy_set_Forwarded()
785 BUF_PTR_LEN(b)); in proxy_set_Forwarded()
788 BUF_PTR_LEN(b)); in proxy_set_Forwarded()
791 b = &r->uri.scheme; in proxy_set_Forwarded()
794 BUF_PTR_LEN(b)); in proxy_set_Forwarded()
841 buffer * const b = chunkqueue_prepend_buffer_open_sz(&hctx->gw.wb, rsz); in proxy_create_env() local
850 buffer_append_str3(b, in proxy_create_env()
855 http_header_remap_uri(b, buffer_clen(b) - buffer_clen(&r->target), in proxy_create_env()
858 buffer_append_string_len(b, !hctx->conf.header.force_http10 in proxy_create_env()
867 buffer_append_str2(b, CONST_STR_LEN("\r\nHost: "), in proxy_create_env()
870 buffer_append_str2(b, CONST_STR_LEN("\r\nHost: "), in proxy_create_env()
874 http_header_remap_host(b, buffer_clen(b) - alen, &hctx->conf.header, 1, alen); in proxy_create_env()
878 b->ptr[b->used-2] = '0'; /*(overwrite end of request line)*/ in proxy_create_env()
902 buffer_append_string_len(b, CONST_STR_LEN("\r\nTransfer-Encoding: chunked")); in proxy_create_env()
952 char * restrict s = buffer_extend(b, klen+vlen+4); in proxy_create_env()
986 http_header_remap_uri(b, buffer_clen(b) - vlen, &hctx->conf.header, 1); in proxy_create_env()
992 buffer_append_string_len(b, CONST_STR_LEN("\r\nConnection: close")); in proxy_create_env()
996 buffer_append_string_len(b, CONST_STR_LEN(", te")); in proxy_create_env()
998 buffer_append_string_len(b, CONST_STR_LEN(", upgrade")); in proxy_create_env()
999 buffer_append_string_len(b, CONST_STR_LEN("\r\n\r\n")); in proxy_create_env()
1013 buffer_append_string_len(b, CONST_STR_LEN( in proxy_create_env()
1015 buffer_append_string_len(b, CONST_STR_LEN( in proxy_create_env()
1020 buffer_append_string_len(b, CONST_STR_LEN("\r\nConnection: close\r\n\r\n")); in proxy_create_env()
1022 hctx->gw.wb_reqlen = buffer_clen(b); in proxy_create_env()