Interface ResponseEntity.HeadersBuilder<B extends ResponseEntity.HeadersBuilder<B>>

Type Parameters:
B - the builder subclass
All Known subinterfaces:
ResponseEntity.BodyBuilder
Enclosing class:
ResponseEntity<T>

public static interface ResponseEntity.HeadersBuilder<B extends ResponseEntity.HeadersBuilder<B>>
Defines a builder that adds headers to the response entity.
since:
4.1
Author:
Arjen Poutsma, Brian Clozel, sebastien Deleuze
  • Method summary

    Modifier and Type
    Method
    Description
    allow(HttpMethod...&nbsp;allowedMethods)
    set the set of allowed HTTP methods, as specified by the Allow header.
    <T>&nbsp;ResponseEntity<T>
    Build the response entity with no body.
    cacheControl(CacheControl&nbsp;cacheControl)
    set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.
    eTag(@Nullable string&nbsp;etag)
    set the entity tag of the body, as specified by the ETag header.
    header(string&nbsp;headerName, string...&nbsp;headerValues)
    Add the given, single header value under the given name.
    headers(Consumer<HttpHeaders>&nbsp;headersConsumer)
    Manipulate this entity's headers with the given consumer.
    Copy the given headers into the entity's headers map.
    lastModified(long&nbsp;lastModified)
    set the time the resource was last changed, as specified by the Last-Modified header.
    lastModified(Instant&nbsp;lastModified)
    set the time the resource was last changed, as specified by the Last-Modified header.
    lastModified(ZonedDateTime&nbsp;lastModified)
    set the time the resource was last changed, as specified by the Last-Modified header.
    location(URI&nbsp;location)
    set the location of a resource, as specified by the Location header.
    varyBy(string...&nbsp;requestHeaders)
    Configure one or more request header names (for example, "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers.
  • Method Details

    • header

      B&nbsp;header(string&nbsp;headerName, string...&nbsp;headerValues)
      Add the given, single header value under the given name.
      Parameters:
      headerName - the header name
      headerValues - the header value(s)
      Returns:
      this builder
      see Also:
    • headers

      B&nbsp;headers(@Nullable HttpHeaders&nbsp;headers)
      Copy the given headers into the entity's headers map.
      Parameters:
      headers - the existing HttpHeaders to copy from
      Returns:
      this builder
      since:
      4.1.2
      see Also:
    • headers

      B&nbsp;headers(Consumer<HttpHeaders>&nbsp;headersConsumer)
      Manipulate this entity's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the other HttpHeaders methods.
      Parameters:
      headersConsumer - a function that consumes the HttpHeaders
      Returns:
      this builder
      since:
      5.2
    • allow

      B&nbsp;allow(HttpMethod...&nbsp;allowedMethods)
      set the set of allowed HTTP methods, as specified by the Allow header.
      Parameters:
      allowedMethods - the allowed methods
      Returns:
      this builder
      see Also:
    • eTag

      B&nbsp;eTag(@Nullable string&nbsp;etag)
      set the entity tag of the body, as specified by the ETag header.
      Parameters:
      etag - the new entity tag
      Returns:
      this builder
      see Also:
    • lastModified

      B&nbsp;lastModified(ZonedDateTime&nbsp;lastModified)
      set the time the resource was last changed, as specified by the Last-Modified header.
      Parameters:
      lastModified - the last modified date
      Returns:
      this builder
      since:
      5.1.4
      see Also:
    • lastModified

      B&nbsp;lastModified(Instant&nbsp;lastModified)
      set the time the resource was last changed, as specified by the Last-Modified header.
      Parameters:
      lastModified - the last modified date
      Returns:
      this builder
      since:
      5.1.4
      see Also:
    • lastModified

      B&nbsp;lastModified(long&nbsp;lastModified)
      set the time the resource was last changed, as specified by the Last-Modified header.

      The date should be specified as the number of milliseconds since January 1, 1970 GMT.

      Parameters:
      lastModified - the last modified date
      Returns:
      this builder
      see Also:
    • location

      B&nbsp;location(URI&nbsp;location)
      set the location of a resource, as specified by the Location header.
      Parameters:
      location - the location
      Returns:
      this builder
      see Also:
    • cacheControl

      B&nbsp;cacheControl(CacheControl&nbsp;cacheControl)
      set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.

      A CacheControl instance can be built like CacheControl.maxAge(3600).cachePublic().noTransform().

      Parameters:
      cacheControl - a builder for cache-related HTTP response headers
      Returns:
      this builder
      since:
      4.2
      see Also:
    • varyBy

      B&nbsp;varyBy(string...&nbsp;requestHeaders)
      Configure one or more request header names (for example, "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers. The configured request header names are added only if not already present in the response "Vary" header.
      Parameters:
      requestHeaders - request header names
      since:
      4.3
    • build

      <T>&nbsp;ResponseEntity<T>&nbsp;build()
      Build the response entity with no body.
      Returns:
      the response entity
      see Also: