From 3fdbe602faaf31848c4762ca64370dd5975cde64 Mon Sep 17 00:00:00 2001 From: yegor256 Date: Fri, 5 May 2017 13:55:17 +0300 Subject: [PATCH] #35 reproduced --- src/main/java/io/jare/tk/TkRelay.java | 6 +++--- src/test/java/io/jare/tk/TkRelayTest.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/jare/tk/TkRelay.java b/src/main/java/io/jare/tk/TkRelay.java index d8e5684..3440b00 100644 --- a/src/main/java/io/jare/tk/TkRelay.java +++ b/src/main/java/io/jare/tk/TkRelay.java @@ -79,7 +79,7 @@ public Response act(final Request req) throws IOException { if (!param.hasNext()) { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, - "parameter \"u\" is mandatory" + "Parameter \"u\" is mandatory" ); } final String target = param.next().trim(); @@ -87,7 +87,7 @@ public Response act(final Request req) throws IOException { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, String.format( - "target URL \"%s\" is not compliant with RFC3986", + "Target URL \"%s\" is not compliant with RFC3986", target ) ); @@ -100,7 +100,7 @@ public Response act(final Request req) throws IOException { HttpURLConnection.HTTP_BAD_REQUEST, String.format( // @checkstyle LineLength (1 line) - "domain \"%s\" is not registered, check your account at www.jare.io", + "Domain \"%s\" is not registered, check your account at www.jare.io", host ) ); diff --git a/src/test/java/io/jare/tk/TkRelayTest.java b/src/test/java/io/jare/tk/TkRelayTest.java index 27e99fd..a669552 100644 --- a/src/test/java/io/jare/tk/TkRelayTest.java +++ b/src/test/java/io/jare/tk/TkRelayTest.java @@ -23,6 +23,7 @@ package io.jare.tk; import io.jare.fake.FkBase; +import java.net.URLEncoder; import java.util.Arrays; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -81,7 +82,7 @@ public void sendsRequestThrough() throws Exception { @Test public void sendsRequestThroughToHome() throws Exception { final Take target = new TkFork( - new FkRegex("/", new TkText("it's home")) + new FkRegex("/.*", new TkText("it's home")) ); new FtRemote(target).exec( home -> MatcherAssert.assertThat( @@ -89,7 +90,13 @@ public void sendsRequestThroughToHome() throws Exception { new TkRelay(new FkBase()).act( new RqFake( Arrays.asList( - String.format("GET /?u=%s", home), + String.format( + "GET /?u=%s", + URLEncoder.encode( + home.resolve("/альфа").toASCIIString(), + "UTF-8" + ) + ), "Host: localhost " ), ""