Document HTTP request snippet’s special treatment of the Host header

For an HTTP 1.1 request to be valid it must contain a Host header. To
ensure that the HTTP request snippet is a valid HTTP 1.1 request a
Host header will always be included. If one is not present in the
request that’s being documented, the snippet will generate one
automatically. A side-effect of this is that a preprocessor that removes
the Host header will have no effect on the HTTP request snippet. This
commit updates the documentation to describe this behaviour.

Closes gh-134
This commit is contained in:
Andy Wilkinson
2015-09-23 10:06:13 +01:00
parent 50514293a8
commit 2fc0420aef
2 changed files with 6 additions and 1 deletions

View File

@@ -77,6 +77,10 @@ different replacement can also be specified if you wish.
`removeHeaders` on `Preprocessors` removes any occurrences of the named headers `removeHeaders` on `Preprocessors` removes any occurrences of the named headers
from the request or response. from the request or response.
NOTE: For an HTTP 1.1 request to be valid it must contain a `Host` header. Therefore,
irrespective of any preprocessing, the default HTTP request snippet will always contain a
`Host` header.
[[customizing-requests-and-responses-preprocessors-replace-patterns]] [[customizing-requests-and-responses-preprocessors-replace-patterns]]

View File

@@ -388,7 +388,8 @@ call that is being documented
| `http-request.adoc` | `http-request.adoc`
| Contains the HTTP request that is equivalent to the `MockMvc` call that is being | Contains the HTTP request that is equivalent to the `MockMvc` call that is being
documented documented. HTTP 1.1 requires a `Host` header. If you do not provide one via the
`MockMvc` API the snippet will add one automatically.
| `http-response.adoc` | `http-response.adoc`
| Contains the HTTP response that was returned | Contains the HTTP response that was returned