Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c65bf8e3
Commit
c65bf8e3
authored
Mar 29, 2018
by
Federico G. Schwindt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include the Host header if not present
Enforced for HTTP/1.1 requests. To disable it use -nohost.
parent
074d66ad
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
r01847.vtc
bin/varnishtest/tests/r01847.vtc
+1
-1
u00003.vtc
bin/varnishtest/tests/u00003.vtc
+3
-3
vtc.c
bin/varnishtest/vtc.c
+1
-1
vtc.h
bin/varnishtest/vtc.h
+1
-0
vtc_http.c
bin/varnishtest/vtc_http.c
+20
-4
No files found.
bin/varnishtest/tests/r01847.vtc
View file @
c65bf8e3
...
...
@@ -24,7 +24,7 @@ client c1 {
expect resp.http.rxhost == www.example.com
expect resp.http.rxurl == /bar
txreq -url https://www.example.com/bar
-hdr "Host: ${localhost}"
txreq -url https://www.example.com/bar
rxresp
expect resp.http.rxhost == "${localhost}"
expect resp.http.rxurl == https://www.example.com/bar
...
...
bin/varnishtest/tests/u00003.vtc
View file @
c65bf8e3
...
...
@@ -32,9 +32,9 @@ shell {
delay 1
client c1 {
txreq -url /1?foo=bar -hdr "authorization: basic dXNlcjpwYXNz"
-hdr "Host: ${localhost}"
txreq -url /1?foo=bar -hdr "authorization: basic dXNlcjpwYXNz"
rxresp
txreq -url /1?foo=bar -hdr "baz: qux"
-hdr "Host: ${localhost}"
txreq -url /1?foo=bar -hdr "baz: qux"
rxresp
} -run
...
...
@@ -44,7 +44,7 @@ shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log"
shell "kill -HUP `cat ${tmpdir}/ncsa.pid`"
client c1 {
txreq -url /2
-hdr "Host: ${localhost}"
txreq -url /2
rxresp
} -run
...
...
bin/varnishtest/vtc.c
View file @
c65bf8e3
...
...
@@ -172,7 +172,7 @@ macro_undef(struct vtclog *vl, const char *instance, const char *name)
AZ
(
pthread_mutex_unlock
(
&
macro_mtx
));
}
static
char
*
char
*
macro_get
(
const
char
*
b
,
const
char
*
e
)
{
struct
macro
*
m
;
...
...
bin/varnishtest/vtc.h
View file @
c65bf8e3
...
...
@@ -114,6 +114,7 @@ void macro_undef(struct vtclog *vl, const char *instance, const char *name);
void
macro_def
(
struct
vtclog
*
vl
,
const
char
*
instance
,
const
char
*
name
,
const
char
*
fmt
,
...)
v_printflike_
(
4
,
5
);
char
*
macro_get
(
const
char
*
,
const
char
*
);
struct
vsb
*
macro_expand
(
struct
vtclog
*
vl
,
const
char
*
text
);
struct
vsb
*
macro_expandf
(
struct
vtclog
*
vl
,
const
char
*
,
...)
v_printflike_
(
2
,
3
);
...
...
bin/varnishtest/vtc_http.c
View file @
c65bf8e3
...
...
@@ -832,11 +832,12 @@ gzip_body(const struct http *hp, const char *txt, char **body, int *bodylen)
static
char
*
const
*
http_tx_parse_args
(
char
*
const
*
av
,
struct
vtclog
*
vl
,
struct
http
*
hp
,
char
*
body
)
char
*
body
,
unsigned
nohost
)
{
int
bodylen
=
0
;
char
*
b
,
*
c
;
char
*
nullbody
;
char
*
m
;
int
nolen
=
0
;
int
l
;
...
...
@@ -846,7 +847,11 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp,
for
(;
*
av
!=
NULL
;
av
++
)
{
if
(
!
strcmp
(
*
av
,
"-nolen"
))
{
nolen
=
1
;
}
else
if
(
!
strcmp
(
*
av
,
"-nohost"
))
{
nohost
=
1
;
}
else
if
(
!
strcmp
(
*
av
,
"-hdr"
))
{
if
(
!
strncasecmp
(
av
[
1
],
"Host:"
,
5
))
nohost
=
1
;
VSB_printf
(
hp
->
vsb
,
"%s%s"
,
av
[
1
],
nl
);
av
++
;
}
else
if
(
!
strcmp
(
*
av
,
"-hdrlen"
))
{
...
...
@@ -904,6 +909,12 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp,
}
else
break
;
}
if
(
!
nohost
)
{
m
=
macro_get
(
"localhost"
,
NULL
);
AN
(
m
);
VSB_printf
(
hp
->
vsb
,
"Host: %s%s"
,
m
,
nl
);
free
(
m
);
}
if
(
body
!=
NULL
&&
!
nolen
)
VSB_printf
(
hp
->
vsb
,
"Content-Length: %d%s"
,
bodylen
,
nl
);
VSB_cat
(
hp
->
vsb
,
nl
);
...
...
@@ -944,8 +955,11 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp,
* These three switches can appear in any order but must come before the
* following ones.
*
* \-nohost
* Don't include a Host header in the request.
*
* \-nolen
* Don't include a Content-Length header
in the response
.
* Don't include a Content-Length header.
*
* \-hdr STRING
* Add STRING as a header, it must follow this format:
...
...
@@ -1019,7 +1033,7 @@ cmd_http_txresp(CMD_ARGS)
/* send a "Content-Length: 0" header unless something else happens */
REPLACE
(
body
,
""
);
av
=
http_tx_parse_args
(
av
,
vl
,
hp
,
body
);
av
=
http_tx_parse_args
(
av
,
vl
,
hp
,
body
,
1
);
if
(
*
av
!=
NULL
)
vtc_fatal
(
hp
->
vl
,
"Unknown http txresp spec: %s
\n
"
,
*
av
);
...
...
@@ -1207,6 +1221,7 @@ cmd_http_txreq(CMD_ARGS)
const
char
*
url
=
"/"
;
const
char
*
proto
=
"HTTP/1.1"
;
const
char
*
up
=
NULL
;
unsigned
nohost
;
(
void
)
cmd
;
(
void
)
vl
;
...
...
@@ -1240,7 +1255,8 @@ cmd_http_txreq(CMD_ARGS)
"Upgrade: h2c%s"
"HTTP2-Settings: %s%s"
,
nl
,
nl
,
up
,
nl
);
av
=
http_tx_parse_args
(
av
,
vl
,
hp
,
NULL
);
nohost
=
strcasecmp
(
proto
,
"HTTP/1.1"
)
!=
0
;
av
=
http_tx_parse_args
(
av
,
vl
,
hp
,
NULL
,
nohost
);
if
(
*
av
!=
NULL
)
vtc_fatal
(
hp
->
vl
,
"Unknown http txreq spec: %s
\n
"
,
*
av
);
http_write
(
hp
,
4
,
"txreq"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment