[ https://issues.apache.org/jira/browse/MRESOLVER-600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881170#comment-17881170 ]
ASF GitHub Bot commented on MRESOLVER-600: ------------------------------------------ doddi commented on code in PR #576: URL: https://github.com/apache/maven-resolver/pull/576#discussion_r1756127277 ########## maven-resolver-transport-jetty/src/main/java/org/eclipse/aether/transport/jetty/JettyRFC9457Reporter.java: ########## @@ -0,0 +1,71 @@ +/* + * 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.jetty; + +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.eclipse.aether.spi.connector.transport.http.HttpTransporterException; +import org.eclipse.aether.spi.connector.transport.http.RFC9457.RFC9457Reporter; +import org.eclipse.jetty.client.api.Response; +import org.eclipse.jetty.client.util.InputStreamResponseListener; +import org.eclipse.jetty.http.HttpHeader; + +public class JettyRFC9457Reporter extends RFC9457Reporter<InputStreamResponseListener, HttpTransporterException> { + @Override + protected boolean isRFC9457Message(final InputStreamResponseListener listener) { + try { + Response response = listener.get(1, TimeUnit.SECONDS); + String contentType = response.getHeaders().get(HttpHeader.CONTENT_TYPE); + return hasRFC9457ContentType(contentType); + } catch (InterruptedException | TimeoutException | ExecutionException e) { + return false; + } + } + + @Override + protected int getStatusCode(final InputStreamResponseListener listener) { + try { + Response response = listener.get(1, TimeUnit.SECONDS); + return response.getStatus(); + } catch (InterruptedException | TimeoutException | ExecutionException e) { + return -1; + } + } + + @Override + protected String getReasonPhrase(final InputStreamResponseListener listener) { + try { + Response response = listener.get(1, TimeUnit.SECONDS); + return response.getReason(); + } catch (InterruptedException | TimeoutException | ExecutionException e) { + return null; + } + } + + @Override + protected String getBody(final InputStreamResponseListener listener) throws IOException { + try (InputStream is = listener.getInputStream()) { + return new String(is.readAllBytes()); Review Comment: https://github.com/apache/maven-resolver/pull/576/commits/156b09517904c13515839562084ac275797911a9 > Implement RFC 9457 > ------------------ > > Key: MRESOLVER-600 > URL: https://issues.apache.org/jira/browse/MRESOLVER-600 > Project: Maven Resolver > Issue Type: New Feature > Components: Resolver > Reporter: Mark Dodgson > Priority: Minor > > HTTP1.1 [RFC > 9112|https://www.rfc-editor.org/rfc/rfc9112.html#name-status-line] section 4 > defines the response status code to optionally include a text description > (human readable) of the reason for the status code. > There is an additional [RFC9457|https://www.rfc-editor.org/rfc/rfc9457] which > makes use of the body to inform of a reason for the error response allowing > for easier investigation. > h2. Why is this important > [RFC9113|https://www.rfc-editor.org/rfc/rfc9113] is the HTTP2 protocol > standard and the response status only considers the [status > code|https://www.rfc-editor.org/rfc/rfc9113#name-response-pseudo-header-fiel] > and not the reason phrase, as such important information can be lost in > helping the client determine a route cause of a failure. -- This message was sent by Atlassian Jira (v8.20.10#820010)