Skip to content

Commit 967a5d1

Browse files
authored
Merge pull request #37 from FusionAuth/degroff/cookie_eq_hash
fix equals and hashCode and add a test.
2 parents a5974bf + 5a67952 commit 967a5d1

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Latest versions
44

5-
* Latest stable version: `1.1.0`
5+
* Latest stable version: `1.1.1`
66
* Now with 100% more virtual threads!
77
* Prior stable version `0.3.7`
88

@@ -27,20 +27,20 @@ To add this library to your project, you can include this dependency in your Mav
2727
<dependency>
2828
<groupId>io.fusionauth</groupId>
2929
<artifactId>java-http</artifactId>
30-
<version>1.1.0</version>
30+
<version>1.1.1</version>
3131
</dependency>
3232
```
3333

3434
If you are using Gradle, you can add this to your build file:
3535

3636
```groovy
37-
implementation 'io.fusionauth:java-http:1.1.0'
37+
implementation 'io.fusionauth:java-http:1.1.1'
3838
```
3939

4040
If you are using Savant, you can add this to your build file:
4141

4242
```groovy
43-
dependency(id: "io.fusionauth:java-http:1.1.0")
43+
dependency(id: "io.fusionauth:java-http:1.1.1")
4444
```
4545

4646
## Examples Usages:

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ restifyVersion = "4.2.1"
1818
slf4jVersion = "2.0.17"
1919
testngVersion = "7.11.0"
2020

21-
project(group: "io.fusionauth", name: "java-http", version: "1.1.0", licenses: ["ApacheV2_0"]) {
21+
project(group: "io.fusionauth", name: "java-http", version: "1.1.1", licenses: ["ApacheV2_0"]) {
2222
workflow {
2323
fetch {
2424
// Dependency resolution order:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.fusionauth</groupId>
44
<artifactId>java-http</artifactId>
5-
<version>1.1.0</version>
5+
<version>1.1.1</version>
66
<packaging>jar</packaging>
77

88
<name>Java HTTP library (client and server)</name>

src/main/java/io/fusionauth/http/Cookie.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,13 @@ public boolean equals(Object o) {
290290
}
291291
return httpOnly == cookie.httpOnly &&
292292
secure == cookie.secure &&
293+
Objects.equals(attributes, cookie.attributes) &&
293294
Objects.equals(domain, cookie.domain) &&
294295
Objects.equals(expires, cookie.expires) &&
295296
Objects.equals(maxAge, cookie.maxAge) &&
296297
Objects.equals(name, cookie.name) &&
297298
Objects.equals(path, cookie.path) &&
299+
sameSite == cookie.sameSite &&
298300
Objects.equals(value, cookie.value);
299301
}
300302

@@ -364,7 +366,16 @@ public boolean hasAttribute(String name) {
364366

365367
@Override
366368
public int hashCode() {
367-
return Objects.hash(domain, expires, httpOnly, maxAge, name, path, secure, value);
369+
return Objects.hash(attributes,
370+
domain,
371+
expires,
372+
httpOnly,
373+
maxAge,
374+
name,
375+
path,
376+
sameSite,
377+
secure,
378+
value);
368379
}
369380

370381
public boolean isHttpOnly() {

src/test/java/io/fusionauth/http/ChunkedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ public void performanceChunked(String scheme) throws Exception {
371371
// REST client which does seem to be fairly predictable, but for example, using a REST client that uses HttpURLConnection is much less
372372
// predictable, but fast. 😀
373373
//
374-
// If it keeps failing, we could modify this assertion to assert 1 or 2.
375-
assertEquals(instrumenter.getConnections(), 1);
374+
// - Going to call this a pass if we have one or two connections.
375+
assertTrue(instrumenter.getConnections() == 1 || instrumenter.getConnections() == 2);
376376
assertEquals(instrumenter.getChunkedResponses(), iterations);
377377
assertEquals(instrumenter.getAcceptedRequests(), iterations);
378378
}

src/test/java/io/fusionauth/http/CookieTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ public void fromResponseHeader() {
309309
cookie = Cookie.fromResponseHeader("=a");
310310
assertNull(cookie);
311311

312+
// Borked coookie, ending with a semicolon;
313+
cookie = Cookie.fromResponseHeader("foo=%2Fbar; Path=/; Secure; HTTPonly;");
314+
assertNull(cookie.domain);
315+
assertNull(cookie.expires);
316+
assertTrue(cookie.httpOnly);
317+
assertNull(cookie.maxAge);
318+
assertEquals(cookie.name, "foo");
319+
assertEquals(cookie.path, "/");
320+
assertNull(cookie.sameSite);
321+
assertTrue(cookie.secure);
322+
assertEquals(cookie.value, "%2Fbar");
323+
312324
// additional attributes
313325
// - name and value
314326
cookie = Cookie.fromResponseHeader("foo=;utm=123");

0 commit comments

Comments
 (0)