kevinsawicki/http-request — pull request #45 by simonbrandhof (2013-07-16 12:03:43+00:00)
Title: Improve exception message when setting request headers after request data

The following code is not allowed by java.net.HttpURLConnection:
HttpRequest.post("").form(dataMap).header("foo", "bar");

An IllegalStateException is thrown with the message "Already connected" because headers must be set before form data.
It's usually not trivial to understand the root problem. So this pull request aims to provide a better and clear message: "Headers must be declared before form data".

Note that the unit tests have been refactored in order to use the JUnit rule "ExpectedException" instead of the @Test parameter "expected". It allows to verify exception message.