doddi commented on code in PR #576: URL: https://github.com/apache/maven-resolver/pull/576#discussion_r1756127061
########## maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkRFC9457Reporter.java: ########## @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.eclipse.aether.transport.jdk; + +import java.io.IOException; +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.util.Optional; + +import org.eclipse.aether.spi.connector.transport.http.HttpTransporterException; +import org.eclipse.aether.spi.connector.transport.http.RFC9457.RFC9457Reporter; + +public class JdkRFC9457Reporter extends RFC9457Reporter<HttpResponse<InputStream>, HttpTransporterException> { + @Override + protected boolean isRFC9457Message(final HttpResponse<InputStream> response) { + Optional<String> optionalContentType = response.headers().firstValue("Content-Type"); + if (optionalContentType.isPresent()) { + String contentType = optionalContentType.get(); + return hasRFC9457ContentType(contentType); + } + return false; + } + + @Override + protected int getStatusCode(final HttpResponse<InputStream> response) { + return response.statusCode(); + } + + @Override + protected String getReasonPhrase(final HttpResponse<InputStream> response) { + return null; + } + + @Override + protected String getBody(final HttpResponse<InputStream> response) throws IOException { + try (InputStream is = response.body()) { + return new String(is.readAllBytes()); Review Comment: https://github.com/apache/maven-resolver/pull/576/commits/156b09517904c13515839562084ac275797911a9 ########## maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-8/src/main/java/org/eclipse/aether/transport/jdk/JdkRFC9457Reporter.java: ########## @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.eclipse.aether.transport.jdk; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; + +import org.eclipse.aether.spi.connector.transport.http.HttpTransporterException; +import org.eclipse.aether.spi.connector.transport.http.RFC9457.RFC9457Reporter; + +public class JdkRFC9457Reporter extends RFC9457Reporter<HttpURLConnection, HttpTransporterException> { + @Override + protected boolean isRFC9457Message(final HttpURLConnection response) { + String contentType = response.getContentType(); + return hasRFC9457ContentType(contentType); + } + + @Override + protected int getStatusCode(final HttpURLConnection response) { + try { + return response.getResponseCode(); + } catch (IOException e) { + return -1; + } + } + + @Override + protected String getReasonPhrase(final HttpURLConnection response) { + return null; + } + + @Override + protected String getBody(final HttpURLConnection response) throws IOException { + try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getInputStream()))) { Review Comment: https://github.com/apache/maven-resolver/pull/576/commits/156b09517904c13515839562084ac275797911a9 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org