Fix empty response error
This commit is contained in:
@@ -13,7 +13,7 @@ public class AboutDialog extends JDialog {
|
||||
public static final int WIDTH = 740;
|
||||
public static final int HEIGHT = 500;
|
||||
|
||||
public static final String VERSION = "0.1.5.2";
|
||||
public static final String VERSION = "0.1.5.3";
|
||||
|
||||
private JPanel contentPane;
|
||||
private JLabel version;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ovh.alexisdelhaie.endpoint.http;
|
||||
|
||||
import ovh.alexisdelhaie.endpoint.configuration.ConfigurationProperties;
|
||||
import ovh.alexisdelhaie.endpoint.utils.MessageDialog;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -88,6 +89,8 @@ public class HttpClient {
|
||||
long time = end.toEpochMilli() - start.toEpochMilli();
|
||||
r.setRawRequest(request);
|
||||
return Optional.of(new Response(b, time, downgraded, r));
|
||||
} catch (Exception e) {
|
||||
MessageDialog.error("HTTP Error", e.getMessage());
|
||||
} finally {
|
||||
s.close();
|
||||
}
|
||||
|
||||
@@ -29,14 +29,18 @@ public class Response {
|
||||
headers = new HashMap<>();
|
||||
rawResponse = new String(res, StandardCharsets.UTF_8);
|
||||
int crlf = rawResponse.indexOf(DOUBLE_CRLF);
|
||||
rawHeaders = rawResponse.substring(0, crlf);
|
||||
parseHeaders();
|
||||
rawResponse = new String(res, getEncoding());
|
||||
body = rawResponse.substring(crlf + DOUBLE_CRLF.length());
|
||||
if (crlf > 0) {
|
||||
rawHeaders = rawResponse.substring(0, crlf);
|
||||
parseHeaders();
|
||||
rawResponse = new String(res, getEncoding());
|
||||
body = rawResponse.substring(crlf + DOUBLE_CRLF.length());
|
||||
parseBody();
|
||||
} else {
|
||||
rawHeaders = rawResponse;
|
||||
}
|
||||
this.time = time;
|
||||
request = r;
|
||||
this.downgraded = downgraded;
|
||||
parseBody();
|
||||
}
|
||||
|
||||
private void parseHeaders() {
|
||||
|
||||
Reference in New Issue
Block a user