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

Properly remove cookie header #166

Merged
merged 1 commit into from
Oct 1, 2024
Merged

Properly remove cookie header #166

merged 1 commit into from
Oct 1, 2024

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Oct 1, 2024

Copy link

quarkus-bot bot commented Oct 1, 2024

Status for workflow Build

This is the status report for running Build on commit f6e79a3.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

if(val.startsWith(cookie.getKey() + "=")) {
it.remove();
}
List<String> newValues = new ArrayList<>(existing.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure existing cannot be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docs, it can never be null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also checked all the implementation and saw that they always return an empty list if the name does not exist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code was more defensive.

}
this.headers.set(HttpHeaderNames.COOKIE, newValues);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it erase the older value or suffix it (headers are multimap), I believe set erase, so it would work, but it needs to be checked.

Copy link
Contributor Author

@geoand geoand Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets a header with the specified name and values. If there is an existing header with the same name, it is removed. This getMethod can be represented approximately as the following code:
  
  headers.remove(name);
  for (Object v: values) {
      if (v == null) {
          break;
      }
      headers. add(name, v);
  }

@geoand geoand requested a review from cescoffier October 1, 2024 14:23
@geoand geoand merged commit cdf13a0 into main Oct 1, 2024
3 checks passed
@geoand geoand deleted the quarkus-#43628 branch October 1, 2024 14:35
@geoand
Copy link
Contributor Author

geoand commented Oct 1, 2024

I assume we'll need a release of this soon :)

@geoand
Copy link
Contributor Author

geoand commented Oct 3, 2024

@cescoffier I will go ahead and (try to) do a release if that's okay with you.

@melloware
Copy link
Contributor

@geoand maybe I am not putting the pieces together but this looks like Vert.X Servlet and I don't see Undertow anywhere in here?

java.lang.UnsupportedOperationException
	at java.base/java.util.AbstractList.remove(AbstractList.java:169)
	at java.base/java.util.AbstractList$Itr.remove(AbstractList.java:389)
	at io.undertow.servlet.spec.PushBuilderImpl.<init>(PushBuilderImpl.java:120)
	at io.undertow.servlet.spec.HttpServletRequestImpl.newPushBuilder(HttpServletRequestImpl.java:1184)

@melloware
Copy link
Contributor

Nevermind I see the classes are io.undertow.servlet.spec.PushBuilderImpl here. My Bad

@geoand
Copy link
Contributor Author

geoand commented Oct 3, 2024

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants