Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package modelengine.fit.http;

import modelengine.fitframework.pattern.builder.BuilderFactory;
import modelengine.fitframework.util.StringUtils;

/**
* 表示 Http 中的 Cookie。
Expand Down Expand Up @@ -210,7 +211,7 @@ interface Builder {
* @return 表示 {@link Cookie} 的构建器的 {@link Builder}。
*/
static Builder builder() {
return builder(null).maxAge(-1);
return builder(null).value(StringUtils.EMPTY).maxAge(-1).secure(false).httpOnly(false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ private static void parseCookieAttributes(String[] parts, Cookie.Builder builder
}

/**
* 验证给定的 Cookie 名称和值是否合法
* 判断给定的 Cookie 名称和值是否无效
*
* @param name 表示 Cookie 的名称 {@link String}。
* @param value 表示 Cookie 的值 {@link String},允许为空但不允许为 {@code null},可带双引号。
* @return 如果 name value 都合法返回 {@code true},否则返回 {@code false}。
* @return 如果 name value 无效返回 {@code true},否则返回 {@code false}。
*/
public static boolean isInvalidCookiePair(String name, String value) {
if (StringUtils.isEmpty(name) || !TOKEN_PATTERN.matcher(name).matches()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void givenValidSetCookieStringThenParseSuccessfully() {
void givenEmptySetCookieThenReturnEmptyCookie() {
Cookie cookie = HttpUtils.parseSetCookie("");
assertThat(cookie.name()).isNull();
assertThat(cookie.value()).isNull();
assertThat(cookie.value()).isEmpty();
}

@Test
Expand Down