async-http-client icon indicating copy to clipboard operation
async-http-client copied to clipboard

Add support java.net.HttpCookie for request

Open PavloVasylchenko opened this issue 10 years ago • 4 comments

It is more convenient to use java.net.HttpCookie because I can specify only name and value for the request. Also it is standard class.

PavloVasylchenko avatar Dec 21 '15 15:12 PavloVasylchenko

No. AHC's cookie class and parser are optimized and don't target stone age RFC 2965.

slandelle avatar Dec 21 '15 15:12 slandelle

From java.net.HttpCookie's javadoc:

There are 3 HTTP cookie specifications:

  • Netscape draft
  • RFC 2109 http://www.ietf.org/rfc/rfc2109.txt
  • RFC 2965 http://www.ietf.org/rfc/rfc2965.txt

HttpCookie class can accept all these 3 forms of syntax.

All modern browsers and frameworks target RFC 6265.

slandelle avatar Dec 21 '15 15:12 slandelle

According to RFC 6265: == User Agent -> Server == Cookie: SID=31d4d96e407aad42 But now if I want to add my own Cookie to the request I have only constructor with all fields: https://github.com/AsyncHttpClient/async-http-client/blob/master/client/src/main/java/org/asynchttpclient/cookie/Cookie.java#L19 Maybe it could be possible to add constructor with less amount of parameters?

PavloVasylchenko avatar Dec 21 '15 15:12 PavloVasylchenko

No:

  • Cookie is immutable, which is a proper design (on contrary to HttpCookie which isn't)
  • constructor overloading is quickly a huge mess to deal with every possible default value combination

The proper solution would be to have a mutable builder. Feel free to contribute one.

slandelle avatar Dec 21 '15 15:12 slandelle