diff options
| author | Wolfgang Baer <WBaer@gmx.de> | 2006-02-09 20:54:56 +0000 |
|---|---|---|
| committer | Wolfgang Baer <WBaer@gmx.de> | 2006-02-09 20:54:56 +0000 |
| commit | 827c5c7a74b251ac2f1c99135c0a6b2bf7d10fd7 (patch) | |
| tree | 24741f447f5f9b2ee07c4b9a2e37c635e67a8c36 /gnu/java/net/protocol/http/Response.java | |
| parent | eb9aa9ad4129ac88dd0c053c9a87b836deea3ab2 (diff) | |
| download | classpath-827c5c7a74b251ac2f1c99135c0a6b2bf7d10fd7.tar.gz | |
2006-02-09 Wolfgang Baer <WBaer@gmx.de>
* gnu/java/net/protocol/http/HTTPURLConnection.java:
(isRedirect): Removed, moved to Response.java.
(connect): If error condition redirect responseSink to errorSink.
(getInputStream): If error condition throw IOException, for the error
codes 404 and 410 throw a FileNotFoundException.
* gnu/java/net/protocol/http/Response.java (isError): New method.
(isRedirect): New method, moved from HTTPURLConnection.java.
Diffstat (limited to 'gnu/java/net/protocol/http/Response.java')
| -rw-r--r-- | gnu/java/net/protocol/http/Response.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gnu/java/net/protocol/http/Response.java b/gnu/java/net/protocol/http/Response.java index 58d74542c..76fac9344 100644 --- a/gnu/java/net/protocol/http/Response.java +++ b/gnu/java/net/protocol/http/Response.java @@ -1,5 +1,5 @@ /* Response.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -188,6 +188,28 @@ public class Response { return headers.getDateValue(name); } + + /** + * Tests whether this response indicates a redirection. + * + * @return <code>true</code> if, <code>false</code> otherwise. + */ + public boolean isRedirect() + { + return (code != 304 && getCodeClass() == 3); + } + + /** + * Tests whether this response indicates an error. + * Errors are the response codes <code>4xx</code> - Client error and + * <code>5xx</code> - Server error. + * + * @return <code>true</code> if, <code>false</code> otherwise. + */ + public boolean isError() + { + return (getCodeClass() == 4 || getCodeClass() == 5); + } /** * Returns an InputStream that returns the body of the response. |
