Skip to content

Have a CookieJar #1235

Closed
Closed
@fangqiao

Description

@fangqiao

Hi,

I am using this lib for testing a custom REST server based on Netty 4.1. 4, the latest, using Scala.

I need to test that cookie has been set correctly at sever side and can be parsed correct on next request.

I used a single DefaultAsyncHttpClient object to submit the first round of request and it received server set cookies successfully.

val httpClient = new  DefaultAsyncHttpClient()

  val request : Request = (new RequestBuilder("POST")).
    setUrl("http://127.0.0.1:9090/login").
    setBody(json).
    build()

  val future : Future[Response] = httpClient.executeRequest(request)


  val response: Response = future.get()

  response.getStatusCode should equal (200)
  val cookies = response.getCookies 

The cookies from server were correctly returned.

Then I used the same DefaultAsyncHttpClient object to submit another request. I supposed the cookies be sent to server automatically. But the netty server was never able to get the cookies from the requests.

Then i tried in the next request by explicitly setting cookies.
val request2: Request = (new RequestBuilder("GET")).
setUrl("http://127.0.0.1:9090/developer").
setCookies(cookies).
build()

This time the netty server can parse the cookies correctly.

I am wondering if it is by design that DefaultAsyncHttpClient will not send server side cookies in next round of request.

If so, I suggest to add the support to coming versions.

If not, what's the correct way to use this feature, which is very useful for my case.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions