Skip to content

Commit 9bfc8f8

Browse files
committed
#8 codereview
1 parent b28e1b7 commit 9bfc8f8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/java/org/cactoos/http/HtCookies.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@
2626
import java.util.HashMap;
2727
import java.util.Map;
2828
import org.cactoos.Input;
29+
import org.cactoos.Text;
2930
import org.cactoos.map.MapEnvelope;
31+
import org.cactoos.text.SplitText;
3032

3133
/**
3234
* Cookies.
3335
*
3436
* @author Vseslav Sekorin (vssekorin@gmail.com)
3537
* @version $Id$
3638
* @since 0.1
37-
* @todo #1:30min The implementation of method stream() can handle only
39+
* @todo #8:30min The implementation of method stream() can handle only
3840
* one Set-Cookie in a response. Fix HtHeaders so that a single key
3941
* may be mapped to one or more values (it is legal to receive more than one
4042
* Set-Cookie in a response).
41-
* @todo #2:30min The implementation of method stream() will break on
43+
* @todo #8:30min The implementation of method stream() will break on
4244
* "flag-type" directives (`Secure`, `HttpOnly`). Fix HtHeaders so that
4345
* these directives are handled correctly.
4446
*/
@@ -52,8 +54,8 @@ public HtCookies(final Input rsp) {
5254
super(() -> {
5355
final Map<String, String> result = new HashMap<>();
5456
final String cookie = new HtHeaders(rsp).get("set-cookie");
55-
for (final String item : cookie.split(";\\s+")) {
56-
final String[] entry = item.split("=", 2);
57+
for (final Text item : new SplitText(cookie, ";\\s+")) {
58+
final String[] entry = item.asString().split("=", 2);
5759
if (entry.length == 2) {
5860
result.put(entry[0], entry[1]);
5961
} else {

src/test/java/org/cactoos/http/HtCookiesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.cactoos.io.InputOf;
2727
import org.cactoos.text.JoinedText;
2828
import org.hamcrest.MatcherAssert;
29-
import org.hamcrest.Matchers;
29+
import org.hamcrest.core.IsEqual;
3030
import org.junit.Test;
3131

3232
/**
@@ -58,7 +58,7 @@ public void takesCookiesOfHttpResponse() {
5858
)
5959
)
6060
).get("domain"),
61-
Matchers.equalTo(".google.com")
61+
new IsEqual<>(".google.com")
6262
);
6363
}
6464

@@ -80,7 +80,7 @@ public void incorrectHttpResponseCookie() {
8080
)
8181
)
8282
).get("domain"),
83-
Matchers.equalTo(".google.com")
83+
new IsEqual<>(".google.com")
8484
);
8585
}
8686
}

0 commit comments

Comments
 (0)