use of org.apache.commons.httpclient.HttpMethod in project pinpoint by naver.
the class HttpMethodBaseExecuteMethodInterceptor method setHttpTraceHeader.
private void setHttpTraceHeader(final Object target, final Object[] args, TraceId nextId) {
if (target instanceof HttpMethod) {
final HttpMethod httpMethod = (HttpMethod) target;
httpMethod.setRequestHeader(Header.HTTP_TRACE_ID.toString(), nextId.getTransactionId());
httpMethod.setRequestHeader(Header.HTTP_SPAN_ID.toString(), String.valueOf(nextId.getSpanId()));
httpMethod.setRequestHeader(Header.HTTP_PARENT_SPAN_ID.toString(), String.valueOf(nextId.getParentSpanId()));
httpMethod.setRequestHeader(Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
httpMethod.setRequestHeader(Header.HTTP_PARENT_APPLICATION_NAME.toString(), traceContext.getApplicationName());
httpMethod.setRequestHeader(Header.HTTP_PARENT_APPLICATION_TYPE.toString(), Short.toString(traceContext.getServerTypeCode()));
final String host = getHost(httpMethod, args);
if (host != null) {
httpMethod.setRequestHeader(Header.HTTP_HOST.toString(), host);
}
}
}
use of org.apache.commons.httpclient.HttpMethod in project pinpoint by naver.
the class HttpMethodBaseExecuteMethodInterceptor method setHttpSampledHeader.
private void setHttpSampledHeader(final Object target) {
if (isDebug) {
logger.debug("set Sampling flag=false");
}
if (target instanceof HttpMethod) {
final HttpMethod httpMethod = (HttpMethod) target;
httpMethod.setRequestHeader(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
}
}
use of org.apache.commons.httpclient.HttpMethod in project tdi-studio-se by Talend.
the class MDMTransaction method commit.
public void commit() throws IOException {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
HttpMethod method = new PostMethod(url + "/" + id);
method.setDoAuthentication(true);
try {
//$NON-NLS-1$ //$NON-NLS-2$
method.setRequestHeader("Cookie", getStickySession() + "=" + sessionId);
client.executeMethod(method);
} catch (HttpException e) {
throw e;
} catch (IOException e) {
throw e;
} finally {
method.releaseConnection();
}
int statuscode = method.getStatusCode();
if (statuscode >= 400) {
throw new MDMTransactionException("Commit failed. The commit operation has returned the code " + statuscode + ".");
}
}
use of org.apache.commons.httpclient.HttpMethod in project zm-mailbox by Zimbra.
the class WebDavClient method sendMultiResponseRequest.
public Collection<DavObject> sendMultiResponseRequest(DavRequest req) throws IOException, DavException {
ArrayList<DavObject> ret = new ArrayList<DavObject>();
HttpMethod m = null;
try {
m = executeFollowRedirect(req);
int status = m.getStatusCode();
if (status >= 400) {
throw new DavException("DAV server returned an error: " + status, status);
}
Document doc = W3cDomUtil.parseXMLToDom4jDocUsingSecureProcessing(m.getResponseBodyAsStream());
Element top = doc.getRootElement();
for (Object obj : top.elements(DavElements.E_RESPONSE)) {
if (obj instanceof Element) {
ret.add(new DavObject((Element) obj));
}
}
} catch (XmlParseException e) {
throw new DavException("can't parse response", e);
} finally {
if (m != null) {
m.releaseConnection();
}
}
return ret;
}
use of org.apache.commons.httpclient.HttpMethod in project zm-mailbox by Zimbra.
the class ElasticSearchIndexTest method indexStoreAvailable.
@Override
protected boolean indexStoreAvailable() {
String indexUrl = String.format("%s?_status", LC.zimbra_index_elasticsearch_url_base.value());
HttpMethod method = new GetMethod(indexUrl);
try {
ElasticSearchConnector connector = new ElasticSearchConnector();
connector.executeMethod(method);
} catch (HttpException e) {
ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
return false;
} catch (IOException e) {
ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
return false;
}
return true;
}
Aggregations