title: Groovy HttpBuilder - Get Body Of Failed Response
body: <p>I am trying to use the Groovy HTTPBuilder to write an integration test that will verify a correct error message is returned in the body along with an HTTP 409 status message. However, I can't figure out how to actually access the body of the HTTP response in failure cases.</p>
  
  <pre><code>http.request(ENV_URL, Method.POST, ContentType.TEXT) {
      uri.path = "/curate/${id}/submit"
      contentType = ContentType.JSON
      response.failure = { failresp_inner -&gt;
          failresp = failresp_inner
      }
  }
  
  then:
  assert failresp.status == 409
  // I would like something like 
  //assert failresp.data == "expected error message"
  </code></pre>
  
  <p>This is what the HTTP response from the server looks like:</p>
  
  <pre><code>2013-11-13 18:17:58,726 DEBUG  wire - &lt;&lt; "HTTP/1.1 409 Conflict[\r][\n]"
  2013-11-13 18:17:58,726 DEBUG  wire - &lt;&lt; "Date: Wed, 13 Nov 2013 23:17:58 GMT[\r][\n]"
  2013-11-13 18:17:58,726 DEBUG  wire - &lt;&lt; "Content-Type: text/plain[\r][\n]"
  2013-11-13 18:17:58,726 DEBUG  wire - &lt;&lt; "Transfer-Encoding: chunked[\r][\n]"
  2013-11-13 18:17:58,727 DEBUG  wire - &lt;&lt; "[\r][\n]"
  2013-11-13 18:17:58,728 DEBUG  wire - &lt;&lt; "E[\r][\n]"
  2013-11-13 18:17:58,728 DEBUG  wire - &lt;&lt; "expected error message"
  2013-11-13 18:17:58,728 DEBUG  wire - &lt;&lt; "[\r][\n]"
  2013-11-13 18:17:58,728 DEBUG  wire - &lt;&lt; "0[\r][\n]"
  2013-11-13 18:17:58,728 DEBUG  wire - &lt;&lt; "[\r][\n]"
  </code></pre>