mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
HttpRequests: decompress error responses if GZip content encoding was set, fix jetbrains.team auth logging
GitOrigin-RevId: 4f96c8eb89ab0569513a714ff3e328f2f8b66368
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9db9c5a2f7
commit
ff72d54c56
@@ -387,14 +387,31 @@ public final class HttpRequests {
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
if (myInputStream == null) {
|
||||
myInputStream = getConnection().getInputStream();
|
||||
if (myBuilder.myGzip && "gzip".equalsIgnoreCase(getConnection().getContentEncoding())) {
|
||||
myInputStream = CountingGZIPInputStream.create(myInputStream);
|
||||
}
|
||||
URLConnection connection = getConnection();
|
||||
myInputStream = unzipStreamIfNeeded(connection, connection.getInputStream());
|
||||
}
|
||||
return myInputStream;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
InputStream getErrorStream() throws IOException {
|
||||
URLConnection connection = getConnection();
|
||||
if (!(connection instanceof HttpURLConnection)) return null;
|
||||
|
||||
InputStream errorStream = ((HttpURLConnection)connection).getErrorStream();
|
||||
if (errorStream == null) return null;
|
||||
|
||||
return unzipStreamIfNeeded(connection, errorStream);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private InputStream unzipStreamIfNeeded(@NotNull URLConnection connection, @NotNull InputStream stream) throws IOException {
|
||||
if (myBuilder.myGzip && "gzip".equalsIgnoreCase(connection.getContentEncoding())) {
|
||||
return CountingGZIPInputStream.create(stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException {
|
||||
@@ -642,7 +659,10 @@ public final class HttpRequests {
|
||||
private static void throwHttpStatusError(HttpURLConnection connection, RequestImpl request, RequestBuilderImpl builder, int responseCode) throws IOException {
|
||||
String message = null;
|
||||
if (builder.myIsReadResponseOnError) {
|
||||
message = HttpUrlConnectionUtil.readString(connection.getErrorStream(), connection);
|
||||
InputStream errorStream = request.getErrorStream();
|
||||
if (errorStream != null) {
|
||||
message = HttpUrlConnectionUtil.readString(errorStream, connection);
|
||||
}
|
||||
}
|
||||
if (StringUtil.isEmpty(message)) {
|
||||
message = "Request failed with status code " + responseCode;
|
||||
|
||||
Reference in New Issue
Block a user