Changeset 35921 in osm for applications
- Timestamp:
- 2022-03-03T15:14:49+01:00 (3 years ago)
- Location:
- applications/editors/josm/plugins/http2/src/org/openstreetmap/josm/plugins/http2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/http2/src/org/openstreetmap/josm/plugins/http2/Http2Client.java
r35791 r35921 37 37 38 38 private static final Map<Duration, HttpClient> clientForConnectTimeout = new ConcurrentHashMap<>(); 39 private static final String USER_AGENT_STRING = "User-Agent"; 39 40 private HttpRequest request; 40 41 private HttpResponse<InputStream> response; … … 57 58 HttpRequest createRequest() throws IOException { 58 59 HttpRequest.Builder requestBuilder; 60 Map<String, String> headers = getHeaders(); 59 61 try { 60 62 requestBuilder = HttpRequest.newBuilder() … … 63 65 ? BodyPublishers.ofByteArray(getRequestBody()) 64 66 : BodyPublishers.noBody()) 65 .header( "User-Agent", Version.getInstance().getFullAgentString());67 .header(USER_AGENT_STRING, headers.getOrDefault(USER_AGENT_STRING, Version.getInstance().getFullAgentString())); 66 68 } catch (URISyntaxException e) { 67 69 throw new IOException(e); … … 78 80 requestBuilder.header("Cache-Control", "no-cache"); 79 81 } 80 for (Map.Entry<String, String> header : getHeaders().entrySet()) {81 if (header.getValue() != null) { 82 for (Map.Entry<String, String> header : headers.entrySet()) { 83 if (header.getValue() != null && !USER_AGENT_STRING.equals(header.getKey())) { 82 84 try { 83 85 requestBuilder.header(header.getKey(), header.getValue()); -
applications/editors/josm/plugins/http2/src/org/openstreetmap/josm/plugins/http2/Http2Plugin.java
r35053 r35921 4 4 import org.openstreetmap.josm.plugins.Plugin; 5 5 import org.openstreetmap.josm.plugins.PluginInformation; 6 import org.openstreetmap.josm.tools.Destroyable; 7 import org.openstreetmap.josm.tools.Http1Client; 6 8 import org.openstreetmap.josm.tools.HttpClient; 7 9 … … 9 11 * Provides HTTP/2 support. 10 12 */ 11 public class Http2Plugin extends Plugin { 13 public class Http2Plugin extends Plugin implements Destroyable { 12 14 13 15 /** … … 19 21 HttpClient.setFactory(Http2Client::new); 20 22 } 23 24 @Override 25 public void destroy() { 26 HttpClient.setFactory(Http1Client::new); 27 } 21 28 }
Note:
See TracChangeset
for help on using the changeset viewer.