Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Set-Cookie attribute names with RFC6265 syntax #2995

Merged
merged 1 commit into from
Jul 4, 2024
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 @@ -34,13 +34,13 @@
* Default implementation of {@link HttpSetCookie}.
*/
public final class DefaultHttpSetCookie implements HttpSetCookie {
private static final String ENCODED_LABEL_DOMAIN = "; domain=";
private static final String ENCODED_LABEL_PATH = "; path=";
private static final String ENCODED_LABEL_EXPIRES = "; expires=";
private static final String ENCODED_LABEL_MAX_AGE = "; max-age=";
private static final String ENCODED_LABEL_HTTP_ONLY = "; httponly";
private static final String ENCODED_LABEL_SECURE = "; secure";
private static final String ENCODED_LABEL_SAMESITE = "; samesite=";
private static final String ENCODED_LABEL_DOMAIN = "; Domain=";
private static final String ENCODED_LABEL_PATH = "; Path=";
private static final String ENCODED_LABEL_EXPIRES = "; Expires=";
private static final String ENCODED_LABEL_MAX_AGE = "; Max-Age=";
private static final String ENCODED_LABEL_HTTP_ONLY = "; HttpOnly";
daschl marked this conversation as resolved.
Show resolved Hide resolved
private static final String ENCODED_LABEL_SECURE = "; Secure";
private static final String ENCODED_LABEL_SAMESITE = "; SameSite=";

private final CharSequence name;
private final CharSequence value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static io.servicetalk.http.api.HttpSetCookie.SameSite.Lax;
import static io.servicetalk.http.api.HttpSetCookie.SameSite.None;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

Expand Down Expand Up @@ -81,4 +82,17 @@ void testNotEqual() {
is(not(new DefaultHttpSetCookie("foo", "bar", "/path", "docs.servicetalk.io",
null, 1L, None, true, false, true).hashCode())));
}

@Test
void testUppercaseNames() {
String encoded = new DefaultHttpSetCookie("foo", "bar", "myPath", "myDomain", "10", 10L, Lax,
false, true, true).encoded().toString();
assertThat(encoded, containsString("Path=myPath"));
assertThat(encoded, containsString("Domain=myDomain"));
assertThat(encoded, containsString("Expires=10"));
assertThat(encoded, containsString("Max-Age=10"));
assertThat(encoded, containsString("SameSite=Lax"));
assertThat(encoded, containsString("HttpOnly"));
assertThat(encoded, containsString("Secure"));
}
}
Loading