-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently GOAWAY is detected/handled only in the connection phase but sometimes can happen in the transfer phase as well. This now wraps the whole request inside a block that is retried if a GOAWAY is detected.
- Loading branch information
Showing
6 changed files
with
212 additions
and
140 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/Headers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Christoph Läubrich and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.net.HttpURLConnection; | ||
import java.net.URI; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface Headers extends AutoCloseable { | ||
|
||
String ENCODING_IDENTITY = "identity"; | ||
String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; | ||
String HEADER_CONTENT_ENCODING = "Content-Encoding"; | ||
String ENCODING_GZIP = "gzip"; | ||
String ETAG_HEADER = "ETag"; | ||
String LAST_MODIFIED_HEADER = "Last-Modified"; | ||
String EXPIRES_HEADER = "Expires"; | ||
String CACHE_CONTROL_HEADER = "Cache-Control"; | ||
String MAX_AGE_DIRECTIVE = "max-age"; | ||
String MUST_REVALIDATE_DIRECTIVE = "must-revalidate"; | ||
|
||
int statusCode() throws IOException; | ||
|
||
Map<String, List<String>> headers(); | ||
|
||
@Override | ||
void close(); | ||
|
||
URI getURI(); | ||
|
||
String getHeader(String header); | ||
|
||
long getLastModified(); | ||
|
||
default void checkResponseCode() throws FileNotFoundException, IOException { | ||
int code = statusCode(); | ||
if (code >= HttpURLConnection.HTTP_BAD_REQUEST) { | ||
if (code == HttpURLConnection.HTTP_NOT_FOUND || code == HttpURLConnection.HTTP_GONE) { | ||
throw new FileNotFoundException(getURI().toString()); | ||
} else { | ||
throw new java.io.IOException("Server returned HTTP code: " + code + " for URL " + getURI().toString()); | ||
} | ||
} | ||
} | ||
|
||
} |
7 changes: 4 additions & 3 deletions
7
p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/HttpTransport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
package org.eclipse.tycho.p2maven.transport; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.eclipse.tycho.p2maven.transport.Response.ResponseConsumer; | ||
|
||
public interface HttpTransport { | ||
|
||
void setHeader(String key, String value); | ||
|
||
Response<InputStream> get() throws IOException; | ||
<T> T get(ResponseConsumer<T> consumer) throws IOException; | ||
|
||
Response<Void> head() throws IOException; | ||
Headers head() throws IOException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.