com.browsermob.api
Interface HttpPostRequest


public interface HttpPostRequest

An object representing an HTTP POST request to be made in the future. The actual request is not made until execute() is called.


Method Summary
 void addFileUpload(java.lang.String name, File file)
          Add the contents of a file to the request, which will make this a multipart request and transmit the file contents as a multipart part.
 void addRequestHeader(java.lang.String key, java.lang.String value)
          Adds an HTTP header with the supplied key and value.
 void addRequestHeaders(NativeObject paramsNO)
          Adds a set of HTTP headers to the HTTP request.
 void addRequestParameter(java.lang.String key, java.lang.String value)
          Adds an HTTP request parameter to be included with the HTTP POST request.
 void addRequestParameters(NativeObject paramsNO)
          Adds a set of HTTP parameters to the HTTP request.
 HttpResponse execute()
          Executes this HTTP POST request.
 void setRequestBody(java.lang.String body)
          Sets the raw content of the HTTP POST body.
 void setRequestBody(java.lang.String body, java.lang.String contentType, java.lang.String charSet)
          Sets the raw content of the HTTP POST body.
 void setRequestBodyAsBase64EncodedBytes(java.lang.String bodyBase64Encoded)
          Sets the raw content of the HTTP POST body using bytes represented in a standard base64 encoding.
 void setVerificationText(java.lang.String verificationText)
          Instructs the HTTP request to look for this string of content against the response content.
 

Method Detail

addRequestHeader

void addRequestHeader(java.lang.String key,
                      java.lang.String value)
Adds an HTTP header with the supplied key and value.

Parameters:
key - the HTTP header key.
value - the HTTP header value.

addRequestHeaders

void addRequestHeaders(NativeObject paramsNO)
Adds a set of HTTP headers to the HTTP request. While the type is documented "NativeObject", this really just means that the argument can be some sort of JavaScript key/value pair. For example, a call might look like the following:

 post.addRequestHeaders({
     header_one: 'some value',
     header_two: ['foo', 'bar']
 });
 

Parameters:
paramsNO - the JavaScript map of headers used when issuing the HTTP request.

setVerificationText

void setVerificationText(java.lang.String verificationText)
Instructs the HTTP request to look for this string of content against the response content. If it is not found, a value of false will be returned by HttpResponse#isContentMatched().

Parameters:
verificationText - the text to check againt the returned content.

addRequestParameter

void addRequestParameter(java.lang.String key,
                         java.lang.String value)
Adds an HTTP request parameter to be included with the HTTP POST request.

Parameters:
key - the HTTP parameter key.
value - the HTTP paramter value.

addRequestParameters

void addRequestParameters(NativeObject paramsNO)
Adds a set of HTTP parameters to the HTTP request. While the type is documented "NativeObject", this really just means that the argument can be some sort of JavaScript key/value pair. For example, a call might look like the following:

 post.addRequestParameters{
     param_one: 'some value',
     param_two: ['foo', 'bar']
 });
 

Parameters:
paramsNO - the JavaScript map of parameters used when issuing an HTTP POST.

setRequestBody

void setRequestBody(java.lang.String body,
                    java.lang.String contentType,
                    java.lang.String charSet)
Sets the raw content of the HTTP POST body. This function is useful for situations where you aren't submitting a normal URL-encoded form request and instead need to control the body directly. This is most often done when simulating SOAP or REST API calls.

Parameters:
body - the body of the HTTP request.
contentType - the content type of the body.
charSet - the character set encoding (eg: UTF-8).

setRequestBody

void setRequestBody(java.lang.String body)
Sets the raw content of the HTTP POST body. This function is useful for situations where you aren't submitting a normal URL-encoded form request and instead need to control the body directly. This is most often done when simulating SOAP or REST API calls.

Parameters:
body - the body of the HTTP request.

setRequestBodyAsBase64EncodedBytes

void setRequestBodyAsBase64EncodedBytes(java.lang.String bodyBase64Encoded)
Sets the raw content of the HTTP POST body using bytes represented in a standard base64 encoding. This function is good for sending raw bytes across the wire.

Parameters:
bodyBase64Encoded - the body of the HTTP request in bytes encoded as a base64 string.

execute

HttpResponse execute()
Executes this HTTP POST request.

Returns:
an object that contains the detailed object results (status code, timings, etc) and whether content verification matched.

addFileUpload

void addFileUpload(java.lang.String name,
                   File file)
Add the contents of a file to the request, which will make this a multipart request and transmit the file contents as a multipart part.

Parameters:
name - the request part name
file - the file to use as the content body. You can get a handle to an uploaded file using BrowserMob#getFile(String)


Copyright © 2011 Neustar, Inc. All Rights Reserved.