Skip to content

Commit 3afd2b0

Browse files
committed
update docs to be more clear
1 parent d886f6a commit 3afd2b0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mkdocs/docs/responses.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Responses
2-
Unirest makes the actual request the moment you invoke of it's ```as[type]``` method. These methods also inform Unirest what type to map the response to. Options are ```Empty```, ```String```, ```File```, ```Object```, ```byte``` and ```Json```.
2+
Unirest makes the actual request the moment you invoke one of its ```as[type]``` methods. These methods also inform Unirest what type to map the response to. Options are ```Empty```, ```String```, ```File```, ```Object```, ```byte``` and ```Json```.
33

44
The response returns as a ```HttpResponse<T>``` where the ```HttpResponse``` object has all of the common response data like status and headers. The Body (if present) can be accessed via the desired type with the ```.getBody()``` method.
55

66
## Empty Responses
7-
If you aren't expecting a body back, ```asEmpty``` is the easiest choice. You will still get back response information like status and headers.
7+
If you aren't expecting a body back, or you don't care about the body, ```asEmpty``` is the easiest choice. You will still get back response information like status and headers. Note that this method effectively ignores any body that might be present.
88

99
```java
10-
HttpResponse response = Unirest.delete("http://localhost").asEmpty()
10+
HttpResponse response = Unirest.delete("http://localhost").asEmpty();
1111
```
1212

1313
## String Responses
1414
The next easiest response type is String. You can do whatever you want with it after that.
1515

1616
```java
1717
String body = Unirest.get("http://localhost")
18-
.asString()
19-
.getBody();
18+
.asString()
19+
.getBody();
2020
```
2121

2222
## Object Mapped Responses
2323
Most of the time when consuming RESTful services you probably want to map the response into an object.
2424

25-
For this you need to provide the Unirest configuration with a implementation of ```ObjectMapper``` (see [Object Mappers](#object-mappers) for details.).
25+
For this you need to provide the Unirest configuration with an implementation of ```ObjectMapper``` (see [Object Mappers](#object-mappers) for details.).
2626

27-
If the response is JSON you are in luck and Unirest comes with a basic ```JsonObjectMapper``` basic on Google GSON
27+
If the response is JSON you are in luck and Unirest comes with a basic ```JsonObjectMapper``` based on Google GSON.
2828

2929
Before an `asObject(Class)` it is necessary to provide a custom implementation of the `ObjectMapper` interface (if you do not wish to use the default mapper). This should be done only the first time, as the instance of the ObjectMapper will be shared globally.
3030

0 commit comments

Comments
 (0)