# C22
recv
- expect ~ "^.* uri: GET http://hostname/c22 HTTP/1.1; host: {hostname:80}$"
+ expect ~ "^.* uri: GET http://hostname/c22 HTTP/1.1; host: {hostname}$"
barrier b1 sync
# C23
recv
- expect ~ "^.* uri: GET https://hostname/c23 HTTP/1.1; host: {hostname:443}$"
+ expect ~ "^.* uri: GET https://hostname/c23 HTTP/1.1; host: {hostname}$"
barrier b1 sync
# C24
# C26
recv
- expect ~ "^.* uri: GET http://hostname/c26 HTTP/1.1; host: {hostname:}$"
+ expect ~ "^.* uri: GET http://hostname/c26 HTTP/1.1; host: {hostname}$"
barrier b1 sync
# C27
recv
- expect ~ "^.* uri: GET https://hostname/c27 HTTP/1.1; host: {hostname:}$"
+ expect ~ "^.* uri: GET https://hostname/c27 HTTP/1.1; host: {hostname}$"
barrier b1 sync
# C28
barrier b1 sync
-# http scheme, no port for the authority but default port for host value => no normalization
+# http scheme, no port for the authority but default port for host value => should be normalized
client c22 -connect ${h1_fe_sock} {
txreq \
-req "GET" \
# Wait matching on log message
barrier b1 sync
-# https scheme, no port for the authority but default port for host value => no normalization
+# https scheme, no port for the authority but default port for host value => should be normalized
client c23 -connect ${h1_fe_sock} {
txreq \
-req "GET" \
# Wait matching on log message
barrier b1 sync
-# http scheme, no port for the authority and empty port for host value => no normalization
+# http scheme, no port for the authority and empty port for host value => should be normalized
client c26 -connect ${h1_fe_sock} {
txreq \
-req "GET" \
# Wait matching on log message
barrier b1 sync
-# https scheme, no port for the authority and empty port for host value => no normalization
+# https scheme, no port for the authority and empty port for host value => should be normalized
client c27 -connect ${h1_fe_sock} {
txreq \
-req "GET" \
*
* The normalization is processed on the target-uri at the condition that it is
* in absolute-form. In the case where the target-uri was normalized, every
- * host headers values found are also replaced by the normalized hostname. This
- * assumes that the target-uri and host headers were properly identify as
- * similar before calling this function.
+ * host headers values found are also replaced by the normalized hostname. In
+ * addition, a host header value carrying the scheme's default port (or an
+ * empty one) is normalized as well even when the authority does not carry any
+ * port, so that the analyser, the ACLs, the cache and the forwarded request
+ * all see the same host value. This assumes that the target-uri and host
+ * headers were properly identify as similar before calling this function.
*/
int http_scheme_based_normalize(struct htx *htx)
{
normalize = 1;
}
+ /* Check for host header normalization if not performe on the authority */
+ if (!normalize) {
+ ctx.blk = NULL;
+ while (http_find_header(htx, ist("host"), &ctx, 1)) {
+ struct ist hval = ctx.value;
+ struct ist hport = http_get_host_port(hval);
+
+ if (!isttest(hport) || !http_is_default_port(scheme, hport))
+ continue;
+ hval = isttrim(hval, istlen(hval) - istlen(hport) - 1);
+ if (!isteqi(hval, host))
+ continue;
+ normalize = 1;
+ break;
+ }
+ }
+
if (normalize) {
/* reconstruct the uri with removal of the port */
struct buffer *temp = alloc_trash_chunk();