Skip to content

Commit

Permalink
use contentEquals to compare AsciiString HeaderValues
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetkhanduri committed Dec 3, 2022
1 parent 67f13a9 commit 20c6eae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/ai/diffy/proxy/HttpEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class HttpEndpoint extends IndependentEndpoint<HttpRequest, HttpResponse>
}
if(req.isFormUrlencoded() &&
HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED
.equals(req.requestHeaders().get(HttpHeaderNames.CONTENT_TYPE))){
.contentEquals(req.requestHeaders().get(HttpHeaderNames.CONTENT_TYPE))){
throw new RuntimeException("Content-Type : application/x-www-form-urlencoded is not supported");
}
return req.receive().aggregate().asString().toFuture().thenApply(body -> new HttpRequest(
Expand Down
12 changes: 12 additions & 0 deletions src/test/scala/ai/diffy/HttpHeaderValuesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ai.diffy;

import io.netty.handler.codec.http.HttpHeaderValues;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class HttpHeaderValuesTest {
@Test
public void urlEncodedHeader() {
assertTrue(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED.contentEquals("application/x-www-form-urlencoded"));
}
}

0 comments on commit 20c6eae

Please sign in to comment.