Example usage for org.apache.commons.httpclient.methods StringRequestEntity getCharset

List of usage examples for org.apache.commons.httpclient.methods StringRequestEntity getCharset

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods StringRequestEntity getCharset.

Prototype

public String getCharset() 

Source Link

Usage

From source file:org.apache.ode.axis2.httpbinding.HttpHelper.java

public static String requestToString(HttpMethod m) {
    StringBuilder sb = new StringBuilder(256);
    try {//from  ww  w  . java 2  s.  co m
        sb.append("HTTP Request Details: \n").append(m.getName()).append(" ").append(m.getURI());
    } catch (URIException e) {
        // not that important
        if (log.isDebugEnabled())
            log.debug(e);
    }
    sb.append("\nRequest Headers:");
    Header[] headers = m.getRequestHeaders();
    if (headers.length == 0)
        sb.append(" n/a");
    for (int i = 0; i < headers.length; i++) {
        Header h = headers[i];
        sb.append("\n\t").append(h.getName()).append(": ").append(h.getValue());
    }
    if (m instanceof EntityEnclosingMethod) {
        EntityEnclosingMethod eem = (EntityEnclosingMethod) m;
        if (eem.getRequestEntity() != null) {
            sb.append("\nRequest Entity:");
            sb.append("\n\tContent-Type:").append(eem.getRequestEntity().getContentType());
            sb.append("\n\tContent-Length:").append(eem.getRequestEntity().getContentLength());
            if (eem.getRequestEntity() instanceof StringRequestEntity) {
                StringRequestEntity sre = (StringRequestEntity) eem.getRequestEntity();
                sb.append("\n\tContent-Charset:").append(sre.getCharset());
                sb.append("\n\tRequest Entity:\n").append(sre.getContent());
            }
        }
    }
    return sb.toString();
}