1. /*
  2. * @(#)HttpRetryException.java 1.1 04/04/20
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.net;
  8. import java.io.IOException;
  9. /**
  10. * Thrown to indicate that a HTTP request needs to be retried
  11. * but cannot be retried automatically, due to streaming mode
  12. * being enabled.
  13. *
  14. * @author Michael McMahon
  15. * @version 1.1, 04/20/04
  16. * @since 1.5
  17. */
  18. public
  19. class HttpRetryException extends IOException {
  20. private int responseCode;
  21. private String location;
  22. /**
  23. * Constructs a new <code>HttpRetryException</code> from the
  24. * specified response code and exception detail message
  25. *
  26. * @param detail the detail message.
  27. * @param code the HTTP response code from server.
  28. */
  29. public HttpRetryException(String detail, int code) {
  30. super(detail);
  31. responseCode = code;
  32. }
  33. /**
  34. * Constructs a new <code>HttpRetryException</code> with detail message
  35. * responseCode and the contents of the Location response header field.
  36. *
  37. * @param detail the detail message.
  38. * @param code the HTTP response code from server.
  39. * @param location the URL to be redirected to
  40. */
  41. public HttpRetryException(String detail, int code, String location) {
  42. super (detail);
  43. responseCode = code;
  44. this.location = location;
  45. }
  46. /**
  47. * Returns the http response code
  48. *
  49. * @return The http response code.
  50. */
  51. public int responseCode() {
  52. return responseCode;
  53. }
  54. /**
  55. * Returns a string explaining why the http request could
  56. * not be retried.
  57. *
  58. * @return The reason string
  59. */
  60. public String getReason() {
  61. return super.getMessage();
  62. }
  63. /**
  64. * Returns the value of the Location header field if the
  65. * error resulted from redirection.
  66. *
  67. * @return The location string
  68. */
  69. public String getLocation() {
  70. return location;
  71. }
  72. }