WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:http:response
Description:
Id:http:response
Category:accessor
Identifier Syntax

http:response is an accessor using a standard identifier grammar:

<grammar>
  <group>httpResponse:/
    <group name="path">
      <regex type="anything" />
    group>
  group>
grammar>

with the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
path(no description available)
Request Verbs

The following verb is supported:

Verb
SINK
Response

The response representation of this accessor for SOURCE requests is unknown.

This accessor throws no documented exceptions.

The HTTPBridge inserts a dynamic space into the request scope it uses when issuing its sub-request into the overlay's wrapped space. This space resolves requests for identifiers using the httpResponse: URI scheme. The httpResponse: address space provides interfaces for information that can be included in the transport's external response to the detected HTTP request. The address space can accept multiple requests with the SINK verb and will serialize all of the accumulated state when the external response is returned to the client.

httpResponse:/cookie

A request with the SINK verb sets an HTTP Cookie for the HTTP transport to include in its external response.

The cookie must be an instance of javax.servlet.http.Cookie and must be set as the primary argument of the request.

For example, the following sets a cookies for the external response:

public void onSource(INKFRequestContext context)
  {
  ...
  response = context.createResponseFrom(representation);
  ...
  Cookie cookie = new Cookie("rememberthis", "special-value");
  cookie.setPath("/");
  cookie.setMaxAge(60000);
  context.sink("httpResponse:/cookie", cookie);
  }

httpResponse:/header/XXXXX

A request with the SINK verb sets an HTTP header value for the HTTP transport to include in its external response. The form of the identifier is:

httpResponse:/header/{header-name}

The header value must be an instance of String and must be set as the primary argument of the request.

For example, the following code sets the header "FROM" to "webmaster@myco.com"

public void onSource(INKFRequestContext context)
  {
  ...
  context.createResponseFrom(representation);
  ...
  context.sink("httpResponse:/header/FROM", "webmaster@myco.com");
  }

Setting headers by this method will override any headers that the HTTP transport may add automatically.

It is possible to remove headers that might have been added automatically by specifying a zero length string:

context.sink("httpResponse:/header/ETag", "");

httpResponse:/code

A request with the SINK verb sets the HTTP response code for the HTTP external response sent by the transport.

For example, to set the response code to "204":

public void onSource(INKFRequestContext context)
  {
  ...
  context.createResponseFrom(representation);
  ...
  context.sink("httpResponse:/code", 204);
  }

httpResponse:/redirect

A request with the SINK verb sets the HTTP code to "302" (redirect) and includes the new resource identifier.

For example, the following code will cause a redirect to be returned by the transport that will redirect the user to the 1060 Research web site:

public void onSource(INKFRequestContext context)
  {
  context.sink("httpResponse:/redirect", "http://www.1060research.com");
  }

Advanced - Response Headers

An alternate mechanism for writing to the response space is to attach response headers that will return to the bridge. i.e.

response.setHeader("httpResponse:/code",404);
is equivalent
context.sink("httpResponse:/code",404);
This will also work for other headers:
response.setHeader("httpResponse:/header/ETag","12345678");

This method of setting headers is usually better because it doesn't effect caching as no SINK requests are made. Also any cached response returned subsequently will also have the headers attached.

HTTP_CACHE_EXPIRES_DELTA_SECONDS

Because the Expires header requires an absolute time a convenience header is provided which gives an offset in seconds from the current time:

//keep http response valid for 60 seconds
response.setHeader("HTTP_CACHE_EXPIRES_DELTA_SECONDS",60);