Skip to content

Commit efb2ebf

Browse files
authored
Merge pull request #546 from wing9405/master
removed remoteHostName from HTTPSession: it can take too long time to…
2 parents b04a342 + cd37235 commit efb2ebf

File tree

4 files changed

+1
-35
lines changed

4 files changed

+1
-35
lines changed

core/src/main/java/org/nanohttpd/protocols/http/HTTPSession.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
import org.nanohttpd.protocols.http.tempfiles.ITempFileManager;
7373

7474
public class HTTPSession implements IHTTPSession {
75-
75+
7676
public static final String POST_DATA = "postData";
7777

7878
private static final int REQUEST_BUFFER_LEN = 512;
@@ -109,8 +109,6 @@ public class HTTPSession implements IHTTPSession {
109109

110110
private String remoteIp;
111111

112-
private String remoteHostname;
113-
114112
private String protocolVersion;
115113

116114
public HTTPSession(NanoHTTPD httpd, ITempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) {
@@ -126,7 +124,6 @@ public HTTPSession(NanoHTTPD httpd, ITempFileManager tempFileManager, InputStrea
126124
this.inputStream = new BufferedInputStream(inputStream, HTTPSession.BUFSIZE);
127125
this.outputStream = outputStream;
128126
this.remoteIp = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "127.0.0.1" : inetAddress.getHostAddress().toString();
129-
this.remoteHostname = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "localhost" : inetAddress.getHostName().toString();
130127
this.headers = new HashMap<String, String>();
131128
}
132129

@@ -698,9 +695,4 @@ private String saveTmpFile(ByteBuffer b, int offset, int len, String filename_hi
698695
public String getRemoteIpAddress() {
699696
return this.remoteIp;
700697
}
701-
702-
@Override
703-
public String getRemoteHostName() {
704-
return this.remoteHostname;
705-
}
706698
}

core/src/main/java/org/nanohttpd/protocols/http/IHTTPSession.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,4 @@ public interface IHTTPSession {
9090
* @return the IP address.
9191
*/
9292
String getRemoteIpAddress();
93-
94-
/**
95-
* Get the remote hostname of the requester.
96-
*
97-
* @return the hostname.
98-
*/
99-
String getRemoteHostName();
10093
}

core/src/test/java/org/nanohttpd/junit/protocols/http/HttpSessionHeadersTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public void testHeadersRemoteIp() throws Exception {
6060
for (String ipAddress : ipAddresses) {
6161
InetAddress inetAddress = InetAddress.getByName(ipAddress);
6262
HTTPSession session = this.testServer.createSession(HttpSessionHeadersTest.TEST_TEMP_FILE_MANAGER, inputStream, outputStream, inetAddress);
63-
assertNotNull(ipAddress, session.getRemoteHostName());
6463
assertEquals(ipAddress, session.getRemoteIpAddress());
6564
}
6665
}

core/src/test/java/org/nanohttpd/junit/protocols/http/HttpSessionTest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,6 @@ public class HttpSessionTest extends HttpServerTest {
4949

5050
private static final TestTempFileManager TEST_TEMP_FILE_MANAGER = new TestTempFileManager();
5151

52-
@Test
53-
public void testSessionRemoteHostnameLocalhost() throws UnknownHostException {
54-
ByteArrayInputStream inputStream = new ByteArrayInputStream(HttpSessionTest.DUMMY_REQUEST_CONTENT.getBytes());
55-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
56-
InetAddress inetAddress = InetAddress.getByName("127.0.0.1");
57-
HTTPSession session = this.testServer.createSession(HttpSessionTest.TEST_TEMP_FILE_MANAGER, inputStream, outputStream, inetAddress);
58-
assertEquals("localhost", session.getRemoteHostName());
59-
}
60-
61-
@Test
62-
public void testSessionRemoteHostname() throws UnknownHostException {
63-
ByteArrayInputStream inputStream = new ByteArrayInputStream(HttpSessionTest.DUMMY_REQUEST_CONTENT.getBytes());
64-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
65-
InetAddress inetAddress = InetAddress.getByName("google.com");
66-
HTTPSession session = this.testServer.createSession(HttpSessionTest.TEST_TEMP_FILE_MANAGER, inputStream, outputStream, inetAddress);
67-
assertEquals("google.com", session.getRemoteHostName());
68-
}
69-
7052
@Test
7153
public void testSessionRemoteIPAddress() throws UnknownHostException {
7254
ByteArrayInputStream inputStream = new ByteArrayInputStream(HttpSessionTest.DUMMY_REQUEST_CONTENT.getBytes());

0 commit comments

Comments
 (0)