Example usage for org.apache.http.protocol ExecutionContext HTTP_RESPONSE

List of usage examples for org.apache.http.protocol ExecutionContext HTTP_RESPONSE

Introduction

In this page you can find the example usage for org.apache.http.protocol ExecutionContext HTTP_RESPONSE.

Prototype

String HTTP_RESPONSE

To view the source code for org.apache.http.protocol ExecutionContext HTTP_RESPONSE.

Click Source Link

Usage

From source file:yangqi.hc.HttpContextTest.java

/**
 * @param args//w w  w  . j  a va  2s. com
 * @throws IOException
 * @throws ClientProtocolException
 */
public static void main(String[] args) throws ClientProtocolException, IOException {
    // TODO Auto-generated method stub
    HttpClient httpclient = new DefaultHttpClient();

    HttpContext context = new BasicHttpContext();

    // Prepare a request object
    HttpGet httpget = new HttpGet("http://www.apache.org/");

    // Execute the request
    HttpResponse response = httpclient.execute(httpget, context);

    showAttr(ExecutionContext.HTTP_CONNECTION, context);
    showAttr(ExecutionContext.HTTP_PROXY_HOST, context);
    showAttr(ExecutionContext.HTTP_REQ_SENT, context);
    showAttr(ExecutionContext.HTTP_RESPONSE, context);
    showAttr(ExecutionContext.HTTP_REQUEST, context);
    showAttr(ExecutionContext.HTTP_TARGET_HOST, context);

}

From source file:com.servoy.extensions.plugins.http.PostRequest.java

/**
 * Get the result page data after a post.
 *
 * @deprecated Replaced by {@link #executeRequest(String,String)}
 *
 * @sample/*  www . ja  v a2 s .com*/
 * var pageData = poster.getPageData()
 */
@Deprecated
public String js_getPageData() {
    try {
        if (context != null) {
            HttpResponse response = (HttpResponse) context.getAttribute(ExecutionContext.HTTP_RESPONSE);
            context = null;
            return EntityUtils.toString(response.getEntity());
        }
    } catch (Exception e) {
        Debug.error(e);
    }
    return ""; //$NON-NLS-1$
}

From source file:org.siddhiesb.transport.passthru.connections.HostConnections.java

public void release(NHttpClientConnection conn) {
    conn.getMetrics().reset();//from ww  w .  ja v a 2 s .  c o  m
    HttpContext ctx = conn.getContext();
    ctx.removeAttribute(ExecutionContext.HTTP_REQUEST);
    ctx.removeAttribute(ExecutionContext.HTTP_RESPONSE);

    lock.lock();
    try {
        if (busyConnections.remove(conn)) {
            freeConnections.add(conn);
        } else {
            log.error("Attempted to releaseConnection connection not in the busy list");
        }
    } finally {
        lock.unlock();
    }
}

From source file:org.apache.axis2.transport.http.server.AxisHttpResponseImpl.java

public void commit() throws IOException, HttpException {
    if (this.commited) {
        return;//  w  ww  . java  2 s  .c  o  m
    }
    this.commited = true;

    this.context.setAttribute(ExecutionContext.HTTP_CONNECTION, this.conn);
    this.context.setAttribute(ExecutionContext.HTTP_RESPONSE, this.response);

    BasicHttpEntity entity = new BasicHttpEntity();
    entity.setChunked(true);
    entity.setContentType(this.contentType);

    this.response.setEntity(entity);

    this.httpproc.process(this.response, this.context);
    this.conn.sendResponse(this.response);
}