Standard Header

Standard headers like Content-Type and Accept are set on your behalf. When payload content is present then values are based on the content type you are sending. When no payload is present, it defaults to application/json .

Common Header

If each http request requires the same header you can specify that header using httpHeaderProvider . Common example is specifying authentication header. package scenarios.rest.headers import scenarios.rest.headers.auth.Auth url = "http://localhost:8080" httpHeaderProvider = Auth.&authHeader Where Auth.&authHeader is implemented as follows: package scenarios.rest.headers.auth import org.testingisdocumenting.webtau.console.ConsoleOutputs import org.testingisdocumenting.webtau.http.HttpHeader class Auth { static HttpHeader authHeader(String fullUrl, String url, HttpHeader original) { ConsoleOutputs.out('auth header injection point') return original.merge([Authorization: 'Bearer <token>']) } } This removes implementation details from your tests and makes them less brittle.

Explicit Header

To explicitly set header pass http.header(values) as an additional parameter. http.get("/end-point", http.header('Accept', 'application/octet-stream')) { // assertions go here } http.get("/end-point", [queryParam1: 'queryParamValue1'], http.header('Accept', 'application/octet-stream')) { // assertions go here } http.patch("/end-point", http.header('Accept', 'application/octet-stream'), [fileId: 'myFile']) { // assertions go here } http.post("/end-point", http.header('Accept', 'application/octet-stream'), [fileId: 'myFile']) { // assertions go here } http.put("/end-point", http.header('Accept', 'application/octet-stream'), [fileId: 'myFile', file: sampleFile]) { // assertions go here } http.delete("/end-point", http.header('Custom-Header', 'special-value')) Additionally http.header accepts values as a map. def varArgHeader = http.header( 'My-Header1', 'Value1', 'My-Header2', 'Value2') def mapBasedHeader = http.header([ 'My-Header1': 'Value1', 'My-Header2': 'Value2']) assert varArgHeader == mapBasedHeader

Mime Type Combined With Payload

Use http.body to combine Content-Type and payload. def content = binaryFile('path') http.post("/end-point", http.body("application/octet-stream", content)) { // assertions go here } If you need a standard type consider using def content = binaryFile('path') http.post("/end-point", http.application.octetStream(content)) { // assertions go here } def content = 'text content' http.post("/end-point", http.text.plain(content)) { // assertions go here }

Response Header

To validate values from response header use header object. http.post("/end-point") { header.location.should == 'http://www.example.org/url/23' header['Location'].should == 'http://www.example.org/url/23' header.contentLocation.should == '/url/23' header['Content-Location'].should == '/url/23' header.contentLength.shouldBe > 300 header['Content-Length'].shouldBe > 300 } At the moment only location , contentLocation , contentLength have camelCase shortcuts. All the other header values you need to use ['Header-Name'] syntax.