Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit be40336

Browse files
committed
Fix #115
Issue was caused by decoder parsing an already decoded query. This would break the decoder method for characters `+` and `&`.
1 parent 165dbeb commit be40336

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<groupId>com.kttdevelopment</groupId>
1212
<artifactId>simplehttpserver</artifactId>
13-
<version>4.1.0</version>
13+
<version>4.2.0</version>
1414

1515
<name>simplehttpserver</name>
1616
<description>📕 SimpleHttpServer :: Simplified implementation of the sun http server :: Simplified handlers to execute complex operations</description>

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @see SimpleHttpExchange
2020
* @since 02.00.00
21-
* @version 4.0.0
21+
* @version 4.2.0
2222
* @author Ktt Development
2323
*/
2424
@SuppressWarnings("SpellCheckingInspection")
@@ -119,7 +119,7 @@ static SimpleHttpExchange create(final HttpExchange exchange){
119119
requestMethod = RequestMethod.UNSUPPORTED; break;
120120
}
121121
//
122-
hasGet = (rawGet = URI.getQuery()) != null;
122+
hasGet = (rawGet = URI.getRawQuery()) != null;
123123
getMap = hasGet ? Collections.unmodifiableMap(parseWwwFormEnc.apply(rawGet)) : new HashMap<>();
124124

125125
//

src/test/java/com/kttdevelopment/simplehttpserver/simplehttpexchange/io/SimpleHttpExchangeGetTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public final void get() throws IOException, ExecutionException, InterruptedExcep
3333
server.start();
3434

3535
final String queryKey = "test", queryValue = "value";
36-
final String url = "http://localhost:" + port + context + '?' + queryKey + '=' + queryValue;
36+
final String altKey = "alt", altValueRaw = "a+?&}", altValueEnc = "a%2B%3F%26%7D";
37+
final String url = "http://localhost:" + port + context + '?' + queryKey + '=' + queryValue + '&' + altKey + '=' + altValueEnc;
3738

3839
HttpRequest request = HttpRequest.newBuilder()
3940
.uri(URI.create(url))
@@ -51,6 +52,7 @@ public final void get() throws IOException, ExecutionException, InterruptedExcep
5152
Assertions.assertEquals(RequestMethod.GET, exchange.getRequestMethod(), "Client request method did not match exchange request method (GET)");
5253
Assertions.assertTrue(exchange.hasGet(), "Exchange was missing client GET map");
5354
Assertions.assertEquals(queryValue, exchange.getGetMap().get(queryKey), "Exchange GET did not match client GET");
55+
Assertions.assertEquals(altValueRaw, exchange.getGetMap().get(altKey), "Exchange GET did not match client GET");
5456
}
5557

5658
}

0 commit comments

Comments
 (0)