Skip to content

Commit edd2ae3

Browse files
pacmano1claude
andcommitted
Remove unused HttpUtil.executeGetRequest
HttpUtil.executeGetRequest has had no callers since the Administrator's Help menu stopped fetching its URL in e2b5878. Its test fetched https://www.nextgen.com, which sent the build machine's address and headers to an outside site on every run and failed offline. Remove both overloads, doExecuteGetRequest and the test. getHttpClient stays, since code outside the engine still calls it. Fixes #313 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Finnegan's Owner <44065187+pacmano1@users.noreply.github.com>
1 parent 89c8f99 commit edd2ae3

2 files changed

Lines changed: 0 additions & 87 deletions

File tree

‎server/src/main/java/com/mirth/connect/util/HttpUtil.java‎

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package com.mirth.connect.util;
1111

12-
import java.nio.charset.Charset;
1312
import java.util.ArrayList;
1413
import java.util.LinkedHashMap;
1514
import java.util.List;
@@ -19,15 +18,8 @@
1918
import javax.net.ssl.HostnameVerifier;
2019
import javax.net.ssl.SSLContext;
2120

22-
import org.apache.commons.io.IOUtils;
23-
import org.apache.http.HttpEntity;
24-
import org.apache.http.HttpStatus;
25-
import org.apache.http.StatusLine;
2621
import org.apache.http.client.config.CookieSpecs;
27-
import org.apache.http.client.config.RequestConfig;
2822
import org.apache.http.client.methods.CloseableHttpResponse;
29-
import org.apache.http.client.methods.HttpGet;
30-
import org.apache.http.client.protocol.HttpClientContext;
3123
import org.apache.http.client.utils.HttpClientUtils;
3224
import org.apache.http.config.RegistryBuilder;
3325
import org.apache.http.config.SocketConfig;
@@ -39,7 +31,6 @@
3931
import org.apache.http.conn.util.PublicSuffixMatcher;
4032
import org.apache.http.conn.util.PublicSuffixMatcherLoader;
4133
import org.apache.http.cookie.CookieSpecProvider;
42-
import org.apache.http.entity.ContentType;
4334
import org.apache.http.impl.client.CloseableHttpClient;
4435
import org.apache.http.impl.client.HttpClientBuilder;
4536
import org.apache.http.impl.client.HttpClients;
@@ -48,7 +39,6 @@
4839
import org.apache.http.impl.cookie.IgnoreSpecProvider;
4940
import org.apache.http.impl.cookie.NetscapeDraftSpecProvider;
5041
import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
51-
import org.apache.http.ssl.SSLContexts;
5242
import org.apache.logging.log4j.LogManager;
5343
import org.apache.logging.log4j.Logger;
5444

@@ -145,57 +135,6 @@ public static Map<String, List<String>> getTableMap(String mapVariable, MessageM
145135
return map;
146136
}
147137

148-
public static String executeGetRequest(String url, int timeout, boolean hostnameVerification, String[] protocols, String[] cipherSuites) {
149-
return executeGetRequest(url, timeout, hostnameVerification, protocols, cipherSuites, SSLContexts.createSystemDefault());
150-
}
151-
152-
public static String executeGetRequest(String url, int timeout, boolean hostnameVerification, String[] protocols, String[] cipherSuites, SSLContext sslContext) {
153-
try {
154-
return doExecuteGetRequest(url, timeout, hostnameVerification, protocols, cipherSuites, sslContext);
155-
} catch (Throwable t) {
156-
logger.error("Error executing GET request at URL " + url, t);
157-
return "";
158-
}
159-
}
160-
161-
static String doExecuteGetRequest(String url, int timeout, boolean hostnameVerification, String[] protocols, String[] cipherSuites, SSLContext sslContext) throws Exception {
162-
CloseableHttpClient client = null;
163-
CloseableHttpResponse response = null;
164-
165-
try {
166-
client = getHttpClient(timeout, hostnameVerification, protocols, cipherSuites, sslContext);
167-
168-
HttpGet get = new HttpGet(url);
169-
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(timeout).setConnectionRequestTimeout(timeout).setSocketTimeout(timeout).build();
170-
HttpClientContext getContext = HttpClientContext.create();
171-
getContext.setRequestConfig(requestConfig);
172-
173-
response = client.execute(get, getContext);
174-
175-
StatusLine statusLine = response.getStatusLine();
176-
int statusCode = statusLine.getStatusCode();
177-
if (statusCode != HttpStatus.SC_OK) {
178-
throw new Exception(statusLine.toString());
179-
}
180-
181-
HttpEntity responseEntity = response.getEntity();
182-
183-
Charset responseCharset = null;
184-
try {
185-
responseCharset = ContentType.getOrDefault(responseEntity).getCharset();
186-
} catch (Exception e) {
187-
responseCharset = ContentType.TEXT_PLAIN.getCharset();
188-
}
189-
190-
return IOUtils.toString(responseEntity.getContent(), responseCharset).trim();
191-
} finally {
192-
if (client != null) {
193-
HttpClientUtils.closeQuietly(response);
194-
HttpClientUtils.closeQuietly(client);
195-
}
196-
}
197-
}
198-
199138
public static CloseableHttpClient getHttpClient(int timeout, boolean hostnameVerification, String[] protocols, String[] cipherSuites, SSLContext sslContext) {
200139
HostnameVerifier hostnameVerifier = hostnameVerification ? new DefaultHostnameVerifier() : NoopHostnameVerifier.INSTANCE;
201140

‎server/src/test/java/com/mirth/connect/util/HttpUtilTest.java‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,17 @@
1010
package com.mirth.connect.util;
1111

1212
import static org.junit.Assert.assertArrayEquals;
13-
import static org.junit.Assert.assertFalse;
14-
import static org.junit.Assert.fail;
1513

16-
import java.security.KeyStore;
1714
import java.util.LinkedHashMap;
1815
import java.util.Map;
19-
import java.util.UUID;
2016

21-
import javax.net.ssl.SSLContext;
22-
23-
import org.apache.commons.lang3.StringUtils;
24-
import org.apache.http.conn.ssl.TrustAllStrategy;
25-
import org.apache.http.ssl.SSLContexts;
2617
import org.junit.Test;
2718

2819
import com.mirth.connect.donkey.model.message.ConnectorMessage;
2920
import com.mirth.connect.donkey.util.MessageMaps;
3021

3122
public class HttpUtilTest {
3223

33-
@Test
34-
public void testExecuteGetRequest() throws Exception {
35-
KeyStore trustStore = KeyStore.getInstance("JKS");
36-
trustStore.load(null, null);
37-
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(trustStore, new TrustAllStrategy()).build();
38-
39-
// Test GET request to real website
40-
assertFalse(StringUtils.isBlank(HttpUtil.doExecuteGetRequest("https://www.nextgen.com", 30000, true, MirthSSLUtil.DEFAULT_HTTPS_CLIENT_PROTOCOLS, MirthSSLUtil.DEFAULT_HTTPS_CIPHER_SUITES, sslContext)));
41-
42-
// Test GET request to fake website
43-
try {
44-
HttpUtil.doExecuteGetRequest("https://www." + UUID.randomUUID().toString() + UUID.randomUUID().toString() + ".com", 30000, true, MirthSSLUtil.DEFAULT_HTTPS_CLIENT_PROTOCOLS, MirthSSLUtil.DEFAULT_HTTPS_CIPHER_SUITES, sslContext);
45-
fail("Exception should have been thrown");
46-
} catch (Exception e) {
47-
}
48-
}
49-
5024
@Test
5125
public void testMapOrderPreserved() throws Exception {
5226
final String MAP_KEY = "MyMap";

0 commit comments

Comments
 (0)