26
26
import java .util .HashMap ;
27
27
import java .util .Map ;
28
28
import org .cactoos .Input ;
29
+ import org .cactoos .Text ;
29
30
import org .cactoos .map .MapEnvelope ;
31
+ import org .cactoos .text .SplitText ;
30
32
31
33
/**
32
34
* Cookies.
33
35
*
34
36
* @author Vseslav Sekorin (vssekorin@gmail.com)
35
37
* @version $Id$
36
38
* @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
38
40
* one Set-Cookie in a response. Fix HtHeaders so that a single key
39
41
* may be mapped to one or more values (it is legal to receive more than one
40
42
* 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
42
44
* "flag-type" directives (`Secure`, `HttpOnly`). Fix HtHeaders so that
43
45
* these directives are handled correctly.
44
46
*/
@@ -52,8 +54,8 @@ public HtCookies(final Input rsp) {
52
54
super (() -> {
53
55
final Map <String , String > result = new HashMap <>();
54
56
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 );
57
59
if (entry .length == 2 ) {
58
60
result .put (entry [0 ], entry [1 ]);
59
61
} else {
0 commit comments