Skip to content

Commit 6aedd0a

Browse files
committed
Remove obsolete org.apache.httpcomponents dependencies
1 parent 0b0dc0a commit 6aedd0a

8 files changed

Lines changed: 664 additions & 511 deletions

File tree

NOTICE.md

Lines changed: 199 additions & 228 deletions
Large diffs are not rendered by default.

etc/licence/third-party-licence-template.ftl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5414,32 +5414,6 @@ This product includes software developed at
54145414
The Apache Software Foundation (http://www.apache.org/).
54155415
```
54165416

5417-
### Apache HttpClient (org.apache.httpcomponents.client5.*)
5418-
5419-
```
5420-
Apache HttpComponents Client
5421-
Copyright 1999-2025 The Apache Software Foundation
5422-
5423-
This product includes software developed at
5424-
The Apache Software Foundation (http://www.apache.org/).
5425-
5426-
This product includes a copy of in https://publicsuffix.org/list/effective_tld_names.dat
5427-
in httpclient5/src/test/resources/org/publicsuffix/list/effective_tld_names.dat
5428-
This Source Code Form is subject to the terms of the Mozilla Public
5429-
License, v. 2.0. If a copy of the MPL was not distributed with this
5430-
file, You can obtain one at https://mozilla.org/MPL/2.0/.
5431-
```
5432-
5433-
### Apache HttpCore / Apache HttpComponents Core (org.apache.httpcomponents.*)
5434-
5435-
```
5436-
Apache HttpComponents Core
5437-
Copyright 2005-2024 The Apache Software Foundation
5438-
5439-
This product includes software developed at
5440-
The Apache Software Foundation (http://www.apache.org/).
5441-
```
5442-
54435417
### Apache Jena (org.apache.jena.*)
54445418

54455419
```

gitb-engine/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@
7171
<groupId>org.freemarker</groupId>
7272
<artifactId>freemarker</artifactId>
7373
</dependency>
74-
<dependency>
75-
<groupId>org.apache.httpcomponents</groupId>
76-
<artifactId>httpmime</artifactId>
77-
</dependency>
7874
<dependency>
7975
<groupId>commons-codec</groupId>
8076
<artifactId>commons-codec</artifactId>
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright (C) 2026 European Union
3+
*
4+
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent
5+
* versions of the EUPL (the "Licence"); You may not use this work except in compliance with the Licence.
6+
*
7+
* You may obtain a copy of the Licence at:
8+
*
9+
* https://interoperable-europe.ec.europa.eu/collection/eupl/eupl-text-eupl-12
10+
*
11+
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an
12+
* "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for
13+
* the specific language governing permissions and limitations under the Licence.
14+
*/
15+
16+
package com.gitb.engine.messaging.handlers.layer.application.http;
17+
18+
import java.io.ByteArrayOutputStream;
19+
import java.io.IOException;
20+
import java.io.InputStream;
21+
import java.io.OutputStream;
22+
import java.nio.charset.StandardCharsets;
23+
import java.util.LinkedHashMap;
24+
import java.util.Map;
25+
26+
/**
27+
* Minimal HTTP/1.1 request/status line, header and body read/write helpers, replacing the wire-level
28+
* functionality previously provided by the Apache HttpCore {@code DefaultBHttpClientConnection} /
29+
* {@code DefaultBHttpServerConnection} classes used by {@link HttpSender} and {@link HttpReceiver}.
30+
* <p>
31+
* This is a deliberately narrow implementation, matching only what those two classes relied on: a request/status
32+
* line, a flat list of headers, and a body sized by the {@code Content-Length} header (always sent by
33+
* {@link HttpSender}, defaulting to {@code 0} otherwise). Chunked transfer encoding is not supported, as it was
34+
* never produced or consumed by this handler.
35+
*/
36+
final class Http11Wire {
37+
38+
static final String CRLF = "\r\n";
39+
40+
private Http11Wire() {
41+
}
42+
43+
static void writeRequestLine(OutputStream out, String method, String path) throws IOException {
44+
writeLine(out, method + " " + path + " HTTP/1.1");
45+
}
46+
47+
static void writeStatusLine(OutputStream out, int statusCode, String reasonPhrase) throws IOException {
48+
writeLine(out, "HTTP/1.1 " + statusCode + " " + reasonPhrase);
49+
}
50+
51+
static void writeHeaders(OutputStream out, Map<String, String> headers) throws IOException {
52+
for (Map.Entry<String, String> header : headers.entrySet()) {
53+
writeLine(out, header.getKey() + ": " + header.getValue());
54+
}
55+
writeLine(out, "");
56+
}
57+
58+
static void writeBody(OutputStream out, byte[] body) throws IOException {
59+
if (body != null && body.length > 0) {
60+
out.write(body);
61+
}
62+
}
63+
64+
private static void writeLine(OutputStream out, String line) throws IOException {
65+
out.write(line.getBytes(StandardCharsets.ISO_8859_1));
66+
out.write('\r');
67+
out.write('\n');
68+
}
69+
70+
/**
71+
* Reads a single CRLF (or bare LF)-terminated line. Returns {@code null} if the stream is at EOF before any
72+
* bytes are read (i.e. the peer closed the connection without sending anything further).
73+
*/
74+
static String readLine(InputStream in) throws IOException {
75+
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
76+
int read;
77+
boolean any = false;
78+
while ((read = in.read()) != -1) {
79+
any = true;
80+
if (read == '\n') {
81+
break;
82+
}
83+
if (read != '\r') {
84+
buffer.write(read);
85+
}
86+
}
87+
if (!any) {
88+
return null;
89+
}
90+
return buffer.toString(StandardCharsets.ISO_8859_1);
91+
}
92+
93+
static LinkedHashMap<String, String> readHeaders(InputStream in) throws IOException {
94+
LinkedHashMap<String, String> headers = new LinkedHashMap<>();
95+
String line;
96+
while ((line = readLine(in)) != null && !line.isEmpty()) {
97+
int separator = line.indexOf(':');
98+
if (separator > 0) {
99+
headers.put(line.substring(0, separator).trim(), line.substring(separator + 1).trim());
100+
}
101+
}
102+
return headers;
103+
}
104+
105+
static byte[] readBody(InputStream in, int contentLength) throws IOException {
106+
if (contentLength <= 0) {
107+
return new byte[0];
108+
}
109+
return in.readNBytes(contentLength);
110+
}
111+
112+
/** Case-insensitive header lookup, matching the case-insensitive header semantics of HTTP. */
113+
static String getHeaderIgnoreCase(Map<String, String> headers, String name) {
114+
for (Map.Entry<String, String> entry : headers.entrySet()) {
115+
if (entry.getKey().equalsIgnoreCase(name)) {
116+
return entry.getValue();
117+
}
118+
}
119+
return null;
120+
}
121+
122+
static String reasonPhrase(int statusCode) {
123+
return switch (statusCode) {
124+
case 200 -> "OK";
125+
case 201 -> "Created";
126+
case 202 -> "Accepted";
127+
case 204 -> "No Content";
128+
case 301 -> "Moved Permanently";
129+
case 302 -> "Found";
130+
case 304 -> "Not Modified";
131+
case 400 -> "Bad Request";
132+
case 401 -> "Unauthorized";
133+
case 403 -> "Forbidden";
134+
case 404 -> "Not Found";
135+
case 405 -> "Method Not Allowed";
136+
case 500 -> "Internal Server Error";
137+
case 502 -> "Bad Gateway";
138+
case 503 -> "Service Unavailable";
139+
default -> "";
140+
};
141+
}
142+
}

0 commit comments

Comments
 (0)