PawelAdamski / HttpClientMock

Library for mocking Apache HttpClient.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for URL-encoded form parameters?

mangstadt opened this issue · comments

This is referring to the parameters that are typically found in the body of POST requests when you submit a <form> on a website.

HttpClientMock client = new HttpClientMock();

//request body looks like: username=John&password=secret%21
//content type is: application/x-www-form-urlencoded

client.verify().post("/login")
  .withBodyParameter("username", "John")
  .withBodyParameter("password", "secret!")
.called();

//or maybe

client.verify().post("/login")
  .withBody(
    new BasicNameValuePair("username", "John"),
    new BasicNameValuePair("password", "secret!")
  )
.called();

I have started looking at the codebase and working on a solution. Do you think this would be useful? Can HttpClientMock already do this?

Merged in #20