Skip to content

Commit e14f42f

Browse files
committed
Update reference for HTTP HEAD and OPTIONS support
Issue: SPR-13130
1 parent 135738f commit e14f42f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/asciidoc/web-mvc.adoc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ are relative to the `/appointments` path. The `get()` method has a further
590590
requests for `appointments/new` are handled by that method.
591591

592592
The `getForDay()` method shows another usage of `@RequestMapping`: URI templates. (See
593-
<<mvc-ann-requestmapping-uri-templates,the next section >>).
593+
<<mvc-ann-requestmapping-uri-templates>>).
594594

595595
A `@RequestMapping` on the class level is not required. Without it, all paths are simply
596596
absolute, and not relative. The following example from the __PetClinic__ sample
@@ -1162,6 +1162,26 @@ respectively instead. They are intended specifically for that purpose.
11621162
====
11631163

11641164

1165+
[[mvc-ann-requestmapping-head-options]]
1166+
==== HTTP HEAD and HTTP OPTIONS
1167+
1168+
`@RequestMapping` methods mapped to "GET" are also implicitly mapped to "HEAD",
1169+
i.e. there is no need to have "HEAD" explicitly declared. An HTTP HEAD request
1170+
is processed as if it was an HTTP GET except instead of writing the body only
1171+
the number of bytes are counted and the "Content-Length" header set.
1172+
1173+
`@RequestMapping` method have built-in support for HTTP OPTIONS. By default an
1174+
HTTP OPTIONS request is handled by setting the "Allow" response header to the
1175+
HTTP methods explicitly declared on all `@RequestMapping` methods with matching
1176+
URL patterns. When no HTTP methods are explicitly declared the "Allow" header
1177+
is set to "GET,HEAD". Therefore it's highly recommended to always explicitly
1178+
declare the HTTP method(s) an `@RequestMapping` method is meant to handle.
1179+
1180+
Although not necessary an `@RequestMapping` method can be mapped to and handle
1181+
either HTTP HEAD or HTTP OPTIONS, or both.
1182+
1183+
1184+
11651185

11661186
[[mvc-ann-methods]]
11671187
=== Defining @RequestMapping handler methods

src/asciidoc/whats-new.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,9 @@ Spring 4.3 also improves the caching abstraction as follows:
661661

662662
=== Web Improvements
663663

664+
* Built-in support for <<mvc-ann-requestmapping-head-options,HTTP HEAD and HTTP OPTIONS>>.
664665
* New `@RestControllerAdvice` annotation combines `@ControllerAdvice` with `@ResponseBody`.
665-
* `@ResponseStatus` can be used on a controller type is inherited for all method.
666+
* `@ResponseStatus` can be used on a controller type and is inherited for all method.
666667
* `AsyncRestTemplate` supports request interception.
667668

668669
=== WebSocket Messaging Improvements

0 commit comments

Comments
 (0)