Skip to content

Commit

Permalink
Remove getTtl(). Closes hapijs#1262
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Dec 21, 2013
1 parent aa4b25f commit 0b41247
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
7 changes: 3 additions & 4 deletions docs/Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,9 @@ for deriving other response types. It provides the following methods:
- `length` - the header value. Must match the actual payload size.
- `vary(header)` - adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header where:
- `header` - the HTTP request header name.
- `location(uri)` - sets the HTTP 'Location' header where:
- `uri` - an absolute or relative URI used as the 'Location' header value. If a relative URI is provided, the value of the server
[`location`](#server.config.location) configuration option is used as prefix.
- `created(location)` - sets the HTTP status code to Created (201) and the HTTP 'Location' header where:
`location` - an absolute or relative URI used as the 'Location' header value. If a relative URI is provided, the value of
the server [`location`](#server.config.location) configuration option is used as prefix. Not available in the `Redirection`
Expand All @@ -1984,7 +1987,6 @@ for deriving other response types. It provides the following methods:
`charset` - the charset property value.
- `ttl(msec)` - overrides the default route cache expiration rule for this response instance where:
- `msec` - the time-to-live value in milliseconds.
- `getTtl()` - returns the time-to-live value if an override has been set, and the request method is 'GET'.
- `state(name, value, [options])` - sets an HTTP cookie as described in [`request.setState()`](#requestsetstatename-value-options).
- `unstate(name)` - clears the HTTP cookie by setting an expired value as described in [`request.clearState()`](#requestclearstatename).

Expand Down Expand Up @@ -2130,9 +2132,6 @@ An HTTP redirection response (3xx). Supports all the methods provided by [`Gener
- `text` - the text content.
- `type` - the 'Content-Type' HTTP header value. Defaults to `'text/html'`.
- `encoding` - the 'Content-Type' HTTP header encoding property. Defaults to `'utf-8'`.
- `location(uri)` - set the destination URI where:
- `uri` - overrides the destination. An absolute or relative URI used as the 'Location' header value. If a relative URI is provided, the
value of the server [`location`](#server.config.location) configuration option is used as prefix.
- `temporary(isTemporary)` - sets the status code to `302` or `307` (based on the `rewritable()` setting) where:
- `isTemporary` - if `false`, sets status to permanent. Defaults to `true`.
- `permanent(isPermanent)` - sets the status code to `301` or `308` (based on the `rewritable()` setting) where:
Expand Down
15 changes: 8 additions & 7 deletions lib/response/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@ internals.Generic.prototype.bytes = function (bytes) {
};


internals.Generic.prototype.location = function (uri) {

this._flags.location = uri;
return this;
};


internals.Generic.prototype.created = function (uri) {

this._code = 201;
this._flags.location = uri;
this.location(uri);
return this;
};

Expand Down Expand Up @@ -121,12 +128,6 @@ internals.Generic.prototype.ttl = function (ttl) {
};


internals.Generic.prototype.getTtl = function () {

return this._code === 200 ? this._flags.ttl : 0;
};


internals.Generic.prototype.state = function (name, value, options) { // options: see Defaults.state

var state = {
Expand Down
2 changes: 1 addition & 1 deletion lib/response/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.location = function (uri, request) {

exports.cache = function (response, request, passThrough) {

var ttl = response.getTtl();
var ttl = response._code === 200 ? response._flags.ttl : 0;

// Check policy

Expand Down
7 changes: 0 additions & 7 deletions lib/response/redirection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ internals.Redirection.prototype._prepare = function (request, callback) {
};


internals.Redirection.prototype.location = function (uri) {

this._flags.location = uri;
return this;
};


internals.Redirection.prototype.temporary = function (isTemporary) {

this._setTemporary(isTemporary !== false); // Defaults to true
Expand Down

0 comments on commit 0b41247

Please sign in to comment.