From 2fc0420aefcdb9df1ca6d90c4748cd48e615d0af Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 23 Sep 2015 10:06:13 +0100 Subject: [PATCH] =?UTF-8?q?Document=20HTTP=20request=20snippet=E2=80=99s?= =?UTF-8?q?=20special=20treatment=20of=20the=20Host=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../src/docs/asciidoc/customizing-requests-and-responses.adoc | 4 ++++ docs/src/docs/asciidoc/documenting-your-api.adoc | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc b/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc index f88a5879..d88fb06d 100644 --- a/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc +++ b/docs/src/docs/asciidoc/customizing-requests-and-responses.adoc @@ -77,6 +77,10 @@ different replacement can also be specified if you wish. `removeHeaders` on `Preprocessors` removes any occurrences of the named headers 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]] diff --git a/docs/src/docs/asciidoc/documenting-your-api.adoc b/docs/src/docs/asciidoc/documenting-your-api.adoc index 7fd84cdf..e0e477f3 100644 --- a/docs/src/docs/asciidoc/documenting-your-api.adoc +++ b/docs/src/docs/asciidoc/documenting-your-api.adoc @@ -388,7 +388,8 @@ call that is being documented | `http-request.adoc` | 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` | Contains the HTTP response that was returned