Package com.jcabi.http.response
Class WebLinkingResponse
java.lang.Object
com.jcabi.http.response.WebLinkingResponse
- All Implemented Interfaces:
Response
Web Linking response.
This response decorator is able to understand and parse Link
HTTP header according to
RFC 5988 "Web Linking",
for example:
String name = new JdkRequest("http://my.example.com")
.fetch()
.as(WebLinkingResponse.class)
.follow("next")
.fetch();
The class is immutable and thread-safe.
- Since:
- 0.9
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends Response>
TConvert it to another type, by encapsulation.final Requestback()Get back to the request it's related to.final byte[]binary()Raw body as an array of bytes.body()Get body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).Follow link by REL.headers()Get a collection of all headers.links()Get all links provided.final Stringreason()Get status line reason phrase.final intstatus()Get status of the response as a positive integer number.final StringtoString()
-
Constructor Details
-
WebLinkingResponse
Public ctor.- Parameters:
resp- Response
-
-
Method Details
-
follow
Follow link by REL.- Parameters:
rel- Relation name- Returns:
- The same object
- Throws:
IOException- If fails
-
links
Get all links provided.- Returns:
- List of all links found
- Throws:
IOException- If fails
-
toString
-
back
Description copied from interface:ResponseGet back to the request it's related to. -
status
public final int status()Description copied from interface:ResponseGet status of the response as a positive integer number. -
reason
Description copied from interface:ResponseGet status line reason phrase. -
headers
Description copied from interface:ResponseGet a collection of all headers. -
body
Description copied from interface:ResponseGet body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).DISCLAIMER: The only encoding supported here is UTF-8. If the body of response contains any chars that can't be used and should be replaced with a "replacement character", a
RuntimeExceptionwill be thrown. If you need to use some other encodings, useResponse.binary()instead. -
binary
public final byte[] binary()Description copied from interface:ResponseRaw body as an array of bytes. -
as
Description copied from interface:ResponseConvert it to another type, by encapsulation.
-