Class StatusMessage
- java.lang.Object
-
- org.drasyl.peer.connection.message.AbstractMessage
-
- org.drasyl.peer.connection.message.StatusMessage
-
- All Implemented Interfaces:
Message
,ResponseMessage<RequestMessage>
public class StatusMessage extends AbstractMessage
Status that representing a HTTP/1.1 response status code, defined in RFC 7231 section 6 (https://tools.ietf.org/html/rfc7231#section-6).Quote:
The status-code element is a positive three-digit integer code giving the result of the attempt to understand and satisfy the request.
HTTP status codes are extensible. HTTP clients are not required to understand the meaning of all registered status codes, though such understanding is obviously desirable. However, a client MUST understand the class of any status code, as indicated by the first digit, and treat an unrecognized status code as being equivalent to the x00 status code of that class, with the exception that a recipient MUST NOT cache a response with an unrecognized status code.
For example, if an unrecognized status code of 471 is received by a client, the client can assume that there was something wrong with its request and treat the response as if it had received a 400 (Bad Request) status code. The response message will usually contain a representation that explains the status.
The first digit of the status-code defines the class of response. The last two digits do not have any categorization role. There are five values for the first digit:
- 1xx (Informational): The request was received, continuing process
- 2xx (Successful): The request was successfully received, understood, and accepted
- 3xx (Redirection): Further action needs to be taken in order to complete the request
- 4xx (Client Error): The request contains bad syntax or cannot be fulfilled
- 5xx (Server Error): The server failed to fulfill an apparently valid request
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StatusMessage.Code
-
Field Summary
Fields Modifier and Type Field Description protected MessageId
correspondingId
-
Fields inherited from class org.drasyl.peer.connection.message.AbstractMessage
id
-
-
Constructor Summary
Constructors Constructor Description StatusMessage(int code, MessageId correspondingId)
StatusMessage(StatusMessage.Code code, MessageId correspondingId)
Creates an immutable code object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
StatusMessage.Code
getCode()
Returns the HTTP status code.MessageId
getCorrespondingId()
int
hashCode()
String
toString()
-
Methods inherited from class org.drasyl.peer.connection.message.AbstractMessage
getId
-
-
-
-
Field Detail
-
correspondingId
protected final MessageId correspondingId
-
-
Constructor Detail
-
StatusMessage
public StatusMessage(int code, MessageId correspondingId)
-
StatusMessage
public StatusMessage(StatusMessage.Code code, MessageId correspondingId)
Creates an immutable code object.- Parameters:
code
- HTTP code codecorrespondingId
-- Throws:
IllegalArgumentException
- if the code isn't a valid code code
-
-
Method Detail
-
getCode
public StatusMessage.Code getCode()
Returns the HTTP status code.- Returns:
- HTTP status code
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object o)
-
toString
public String toString()
- Overrides:
toString
in classAbstractMessage
-
getCorrespondingId
public MessageId getCorrespondingId()
- Specified by:
getCorrespondingId
in interfaceResponseMessage<R extends RequestMessage>
- Returns:
- the id of the
RequestMessage
to which this response corresponds
-
-