Added checks in prettifyResponseBody for when there's no response body
This commit is contained in:
parent
0cd3ad940a
commit
b57c6a9136
3 changed files with 14 additions and 10 deletions
BIN
docs/Credits.odt
BIN
docs/Credits.odt
Binary file not shown.
|
@ -340,13 +340,20 @@ public class DashboardController implements Initializable {
|
|||
}
|
||||
|
||||
private void prettifyResponseBody(RestaurantResponse response) {
|
||||
String type = response.getMediaType().toString();
|
||||
// Selects only the part preceding the ';', skipping the character encoding
|
||||
type = type.split(";")[0];
|
||||
String type;
|
||||
|
||||
if (response.getMediaType() != null)
|
||||
type = response.getMediaType().toString();
|
||||
else
|
||||
type = null;
|
||||
|
||||
String responseBody = response.getBody();
|
||||
|
||||
try {
|
||||
if (type != null) {
|
||||
// Selects only the part preceding the ';', skipping the character encoding
|
||||
type = type.split(";")[0];
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
case "application/json":
|
||||
responseType.setText("JSON");
|
||||
|
@ -366,7 +373,8 @@ public class DashboardController implements Initializable {
|
|||
responseArea.setText(responseBody);
|
||||
}
|
||||
} else {
|
||||
response.setBody("No body found in the response.");
|
||||
responseType.setText("NONE");
|
||||
responseArea.setText("No body found in the response.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
snackBar.show("Response could not be parsed.", 5000);
|
||||
|
|
|
@ -223,7 +223,8 @@
|
|||
</JFXButton>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox fx:id="promptLayer" alignment="CENTER" prefHeight="200.0" prefWidth="100.0" visible="false">
|
||||
<VBox fx:id="promptLayer" alignment="CENTER" prefHeight="200.0"
|
||||
prefWidth="100.0">
|
||||
<children>
|
||||
<Label text="Enter an address, select a method and hit send."
|
||||
textFill="WHITE">
|
||||
|
@ -231,11 +232,6 @@
|
|||
<Font size="32.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label text="🚀" textFill="#0093ff">
|
||||
<font>
|
||||
<Font size="43.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox fx:id="errorLayer" alignment="CENTER" layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="100.0" visible="false">
|
||||
|
|
Loading…
Reference in a new issue