Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Set-Cookie: need ability to set value without URL encoding #127

Closed
ademarre opened this issue Aug 14, 2017 · 0 comments
Closed

Set-Cookie: need ability to set value without URL encoding #127

ademarre opened this issue Aug 14, 2017 · 0 comments

Comments

@ademarre
Copy link
Contributor

ademarre commented Aug 14, 2017

Zend\Http\Header\SetCookie should allow setting the value without URL encoding it, similar to PHP's setrawcookie() function. This can be necessary for compatibility with other libraries, or when you know that all characters are safe and no escaping is necessary.

For example, a cookie whose value might contain a colon (:) is perfectly valid:

Set-Cookie:foo=a:b; Path=/

But currently it can only be set like this:

Set-Cookie:foo=a%3Ab; Path=/

API consistency considerations:

  • Zend\Http\Header\Cookie has a setEncodeValue() method that can be used to toggle whether cookie values are URL encoded.
  • SetCookie has setQuoteFieldValue() and hasQuoteFieldValue() methods. This quoting is applied to the same header component as URL encoding. In my opinion, these names are misleading, since the quoting applies only to the cookie value itself, not the entire "field value", as the term is typically used. This is only a minor concern though, as anyone familiar enough with the spec to want quotes probably knows what it does.
  • Adding setEncodeFieldValue() / hasEncodeFieldValue() would be consistent with the precedent set by setQuoteFieldValue(), but slightly misleading.
  • setEncodeValue() / getEncodeValue() are more accurate names and are consistent with the Cookie class.
  • setEncodeValue() / hasEncodeValue() is consistent with the "set" / "has" terminology used for SetCookie's quote methods, but doesn't make the mistake of implying the entire field value is encoded.
thomasvargiu added a commit to thomasvargiu/zend-http that referenced this issue Oct 13, 2018
thomasvargiu added a commit to thomasvargiu/zend-http that referenced this issue Oct 13, 2018
weierophinney added a commit that referenced this issue Jan 8, 2019
…ded-value

#127 Set-Cookie: added ability to set value without URL encoding
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant