}
public BrowserMobHttpResponse execute() {
// deal with PUT/POST requests
if (method instanceof HttpEntityEnclosingRequestBase) {
HttpEntityEnclosingRequestBase enclodingRequest = (HttpEntityEnclosingRequestBase) method;
if (!nvps.isEmpty()) {
try {
if (!multiPart) {
enclodingRequest.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
} else {
for (NameValuePair nvp : nvps) {
multipartEntity.addPart(nvp.getName(), new StringBody(nvp.getValue()));
}
enclodingRequest.setEntity(multipartEntity);
}
} catch (UnsupportedEncodingException e) {
LOG.severe("Could not find UTF-8 encoding, something is really wrong", e);
}
} else if (multipartEntity != null) {
enclodingRequest.setEntity(multipartEntity);
} else if (byteArrayEntity != null) {
enclodingRequest.setEntity(byteArrayEntity);
} else if (stringEntity != null) {
enclodingRequest.setEntity(stringEntity);
} else if (inputStreamEntity != null) {
enclodingRequest.setEntity(inputStreamEntity);
}
}
return client.execute(this);
}