thekid/rfc — Issue #28: RFC 0028: Add a method forwardTo() to XMLScriptletResponse
Author: thekid
Created: 2011-10-09 14:15:54+00:00
State: open

Scope of Change
====
A new method forwardTo() will be added to the XMLScriptletResponse class.
This method will redirect relatively to the base URI.

Rationale
====
A redirect (HTTP statuscodes 301 / 302 with Location header) needs an
absolute URI to be RFC-conform. Assembling this URI is tedious and
developers tend to end up writing $response->redirect('../foo/bar'),
which works fine because browsers are quite relaxed on this issue.

Functionality
====

Current functionality
----

```php
getURI();
$sessionId= $request->session ? $request->session->getId() : NULL;
$response->sendRedirect(sprintf(
'%s://%s/xml/%s.%s%s/%s%s%s',
$uri['scheme'],
$uri['host'],
$request->getProduct(),
$request->getLanguage(),
empty($sessionId) ? '' : '.psessionid='.$sessionId,
$stateName,
empty($query) ? '' : '?'.$query,
empty($fraction) ? '' : '#'.$fraction
));
?>
```

New functionality
----

```php
forwardTo($stateName);

// Also attach a query string and a fraction, e.g. {
// stateName: 'news/view'
// query: '5'
// fraction: 'extended'
// }
$response->forwardTo($stateName, $query, $fraction);
?>
```

Note that neither the query argument nor the fraction argument contain
the separators ("?" for query, "#" for fraction)!

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
- New method in XMLScriptletResponse

Related documents
====
- Patch implementing this RFC
http://xp-framework.net/downloads/rfc0028.diff

Comments
====
n/a