-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added status code 308 #582
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,6 +791,21 @@ public static ResponseBuilder temporaryRedirect(URI location) { | |
return status(Status.TEMPORARY_REDIRECT).location(location); | ||
} | ||
|
||
/** | ||
* Create a new ResponseBuilder for a permanent redirection. | ||
* | ||
* @param location the redirection URI. If a relative URI is | ||
* supplied it will be converted into an absolute URI by resolving it | ||
* relative to the base URI of the application (see | ||
* {@link UriInfo#getBaseUri}). | ||
* @return a new response builder. | ||
* @throws java.lang.IllegalArgumentException | ||
* if location is {@code null}. | ||
*/ | ||
public static ResponseBuilder permanentRedirect(URI location) { | ||
return status(Status.PERMANENT_REDIRECT).location(location); | ||
} | ||
|
||
/** | ||
* Create a new ResponseBuilder for a not acceptable response. | ||
* | ||
|
@@ -1296,6 +1311,10 @@ public enum Status implements StatusType { | |
* 307 Temporary Redirect, see {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8">HTTP/1.1 documentation</a>}. | ||
*/ | ||
TEMPORARY_REDIRECT(307, "Temporary Redirect"), | ||
/** | ||
* 308 Permanent Redirect, see {@link <a href="https://tools.ietf.org/html/rfc7538">HTTP/1.1 documentation</a>}. | ||
*/ | ||
PERMANENT_REDIRECT(308, "Permanent Redirect"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this PR, but still: what's the point in citing RFC 2616? It has been obsoleted years ago. |
||
/** | ||
* 400 Bad Request, see {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">HTTP/1.1 documentation</a>}. | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced that a shortcut method
permanentRedirect
is required. A lot of other, IMO more important, status codes don't have shortcut methods either. I would rather not bloat this class with another method -- if we decide to add the enum.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I share this opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, these shortcut methods are especially important for status codes that need additional headers to be set. Playing devil's advocate here, actually 308 would be a good example for a status method for which a shortcut method would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkarg @sdaschner : I suggest for now, lets keep it as is ...ie to have the shortcut method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only consider adding this method if a majority agrees on its usefulness. And currently most comments questioned it. So let's wait for other comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spericas Does that mean "plus one" or "zero" from your side? Just for correctly counting votes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sdaschner "Minus one" due to the shortcut method, or "zero" because it was only a comment? Just for counting votes correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zero then. When I think about it more, I do see the advantage that you want to add an URI, similar to
created
, what @chkal mentioned.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkarg It is a +1 for me. This error code is widely supported in all major browsers, that is good enough for me. As I said, I also don't have a problem keeping the static method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sum so far (as not everybody used the Github review tool): chkal 0, mkarg -1, spericas +1, sdaschner 0 => result 0.