Skip to content

Commit d17954a

Browse files
committed
Merge branch '__rultor'
2 parents 14d1d4f + f28cb5a commit d17954a

File tree

8 files changed

+23
-42
lines changed

8 files changed

+23
-42
lines changed

src/main/java/org/takes/facets/auth/PsBasic.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ public PsBasic(final String rlm, final PsBasic.Entry basic) {
8787

8888
@Override
8989
public Opt<Identity> enter(final Request request) throws IOException {
90-
final Iterator<String> headers = new RqHeaders.Smart(
91-
new RqHeaders.Base(request)
92-
).header("authorization").iterator();
90+
final Iterator<String> headers = new RqHeaders.Smart(request)
91+
.header("authorization").iterator();
9392
if (!headers.hasNext()) {
9493
throw new RsForward(
9594
new RsWithHeader(

src/main/java/org/takes/facets/fork/FkHost.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ public FkHost(final String host, final Take take) {
6868
*/
6969
private static Fork fork(final String host, final Take take) {
7070
return req -> {
71-
final String hst = new RqHeaders.Smart(
72-
new RqHeaders.Base(req)
73-
).single("host");
71+
final String hst = new RqHeaders.Smart(req).single("host");
7472
return new Ternary<Opt<Response>>(
7573
new EqualsNullable(
7674
new Lowered(host), new Lowered(hst)

src/main/java/org/takes/rq/RqSocket.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public RqSocket(final Request req) {
5353
*/
5454
public InetAddress getLocalAddress() throws IOException {
5555
return InetAddress.getByName(
56-
new RqHeaders.Smart(new RqHeaders.Base(this))
57-
.single("X-Takes-LocalAddress")
56+
new RqHeaders.Smart(this).single("X-Takes-LocalAddress")
5857
);
5958
}
6059

@@ -65,8 +64,7 @@ public InetAddress getLocalAddress() throws IOException {
6564
*/
6665
public InetAddress getRemoteAddress() throws IOException {
6766
return InetAddress.getByName(
68-
new RqHeaders.Smart(new RqHeaders.Base(this))
69-
.single("X-Takes-RemoteAddress")
67+
new RqHeaders.Smart(this).single("X-Takes-RemoteAddress")
7068
);
7169
}
7270

@@ -77,8 +75,7 @@ public InetAddress getRemoteAddress() throws IOException {
7775
*/
7876
public int getLocalPort() throws IOException {
7977
return Integer.parseInt(
80-
new RqHeaders.Smart(new RqHeaders.Base(this))
81-
.single("X-Takes-LocalPort")
78+
new RqHeaders.Smart(this).single("X-Takes-LocalPort")
8279
);
8380
}
8481

@@ -89,8 +86,7 @@ public int getLocalPort() throws IOException {
8986
*/
9087
public int getRemotePort() throws IOException {
9188
return Integer.parseInt(
92-
new RqHeaders.Smart(new RqHeaders.Base(this))
93-
.single("X-Takes-RemotePort")
89+
new RqHeaders.Smart(this).single("X-Takes-RemotePort")
9490
);
9591
}
9692
}

src/main/java/org/takes/rq/multipart/RqMtFake.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ private FakeBody(final Request... parts) {
164164
.append(RqMtFake.CRLF)
165165
.append("Content-Disposition: ")
166166
.append(
167-
new RqHeaders.Smart(
168-
new RqHeaders.Base(part)
169-
).single("Content-Disposition")
167+
new RqHeaders.Smart(part).single("Content-Disposition")
170168
).append(RqMtFake.CRLF);
171169
final String body = new RqPrint(part).printBody();
172170
if (!(RqMtFake.CRLF.equals(body) || body.isEmpty())) {

src/main/java/org/takes/tk/TkCors.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public TkCors(final Take take, final String... domains) {
7575
@Override
7676
public Response act(final Request req) throws Exception {
7777
final Response response;
78-
final String domain = new RqHeaders.Smart(
79-
new RqHeaders.Base(req)
80-
).single("origin", "");
78+
final String domain = new RqHeaders.Smart(req).single("origin", "");
8179
if (this.allowed.contains(domain)) {
8280
response = new RsWithHeaders(
8381
this.origin.act(req),

src/main/java/org/takes/tk/TkSslOnly.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public TkSslOnly(final Take take) {
5959
@Override
6060
public Response act(final Request req) throws Exception {
6161
final String href = new RqHref.Base(req).href().toString();
62-
final String proto = new RqHeaders.Smart(
63-
new RqHeaders.Base(req)
64-
).single("x-forwarded-proto", "https");
62+
final String proto = new RqHeaders.Smart(req).single("x-forwarded-proto", "https");
6563
final Response answer;
6664
if ("https".equalsIgnoreCase(proto)) {
6765
answer = this.origin.act(req);

src/test/java/org/takes/http/BkBasicTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ void addressesInHeadersAddedWithoutSlashes() throws Exception {
137137
}
138138
).accept(socket);
139139
final Request request = ref.get();
140-
final RqHeaders.Smart smart = new RqHeaders.Smart(
141-
new RqHeaders.Base(request)
142-
);
140+
final RqHeaders.Smart smart = new RqHeaders.Smart(request);
143141
MatcherAssert.assertThat(
144142
smart.single(
145143
"X-Takes-LocalAddress",

src/test/java/org/takes/rq/RqHeadersTest.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ void findsAllHeaders() throws IOException {
8686
void returnsSingleHeader() throws IOException {
8787
MatcherAssert.assertThat(
8888
new RqHeaders.Smart(
89-
new RqHeaders.Base(
90-
new RqFake(
91-
Arrays.asList(
92-
"GET /g",
93-
"Host: www.takes.com"
94-
),
95-
""
96-
)
89+
new RqFake(
90+
Arrays.asList(
91+
"GET /g",
92+
"Host: www.takes.com"
93+
),
94+
""
9795
)
9896
).single("host", "www.takes.net"),
9997
Matchers.equalTo("www.takes.com")
@@ -109,14 +107,12 @@ void returnsDefaultHeader() throws IOException {
109107
final String type = "text/plain";
110108
MatcherAssert.assertThat(
111109
new RqHeaders.Smart(
112-
new RqHeaders.Base(
113-
new RqFake(
114-
Arrays.asList(
115-
"GET /f",
116-
"Accept: text/json"
117-
),
118-
""
119-
)
110+
new RqFake(
111+
Arrays.asList(
112+
"GET /f",
113+
"Accept: text/json"
114+
),
115+
""
120116
)
121117
).single("Content-type", type),
122118
Matchers.equalTo(type)

0 commit comments

Comments
 (0)