List of usage examples for org.apache.commons.httpclient StatusLine getHttpVersion
public final String getHttpVersion()
From source file:com.springsource.insight.plugin.apache.http.hc3.HttpPlaceholderMethodTest.java
@Test public void testPlaceholderMethodContents() throws URIException { assertEquals("Mismatched method", HttpClientDefinitions.PLACEHOLDER_METHOD_NAME, HttpPlaceholderMethod.PLACEHOLDER.getName()); assertEquals("Mismatched URI", HttpClientDefinitions.PLACEHOLDER_URI_VALUE, String.valueOf(HttpPlaceholderMethod.PLACEHOLDER.getURI())); StatusLine statusLine = HttpPlaceholderMethod.PLACEHOLDER.getStatusLine(); assertEquals("Mismatched HTTP version", "HTTP/1.1", statusLine.getHttpVersion()); assertEquals("Mismatched status code", 500, statusLine.getStatusCode()); }
From source file:org.apache.ode.axis2.httpbinding.HttpClientHelper.java
/** * Convert a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1">HTTP status line</a> into an xml element like this: * <p/>//from w w w . ja va 2 s . c o m * < Status-line> * < HTTP-Version>HTTP/1.1< /HTTP-Version> * < Status-Code>200< /Status-Code> * < Reason-Phrase>Success - The action was successfully received, understood, and accepted< /Reason-Phrase> * < /Status-line></br> * * @param statusLine - the {@link org.apache.commons.httpclient.StatusLine} instance to be converted * @param doc - the document to use to create new nodes * @return an Element */ public static Element statusLineToElement(Document doc, StatusLine statusLine) { Element statusLineEl = doc.createElementNS(null, "Status-Line"); Element versionEl = doc.createElementNS(null, "HTTP-Version"); Element codeEl = doc.createElementNS(null, "Status-Code"); Element reasonEl = doc.createElementNS(null, "Reason-Phrase"); // wiring doc.appendChild(statusLineEl); statusLineEl.appendChild(versionEl); statusLineEl.appendChild(codeEl); statusLineEl.appendChild(reasonEl); // values versionEl.setTextContent(statusLine.getHttpVersion()); codeEl.setTextContent(String.valueOf(statusLine.getStatusCode())); reasonEl.setTextContent(statusLine.getReasonPhrase()); return statusLineEl; }
From source file:org.apache.ode.axis2.httpbinding.HttpHelper.java
/** * Convert a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1">HTTP status line</a> into an xml element like this: * <p/>/*www.j a v a 2 s .com*/ * < Status-line> * < HTTP-Version>HTTP/1.1< /HTTP-Version> * < Status-Code>200< /Status-Code> * < Reason-Phrase>Success - The action was successfully received, understood, and accepted< /Reason-Phrase> * < /Status-line></br> * * @param statusLine - the {@link org.apache.commons.httpclient.StatusLine} instance to be converted * @param doc - the document to use to create new nodes * @return an Element */ public static Element statusLineToElement(Document doc, StatusLine statusLine) { Element statusLineEl = doc.createElementNS(null, "Status-Line"); Element versionEl = doc.createElementNS(null, "HTTP-Version"); Element codeEl = doc.createElementNS(null, "Status-Code"); Element reasonEl = doc.createElementNS(null, "Reason-Phrase"); Element originalEl = doc.createElementNS(null, "original"); // wiring doc.appendChild(statusLineEl); statusLineEl.appendChild(versionEl); statusLineEl.appendChild(codeEl); statusLineEl.appendChild(reasonEl); statusLineEl.appendChild(originalEl); // values versionEl.setTextContent(statusLine.getHttpVersion()); codeEl.setTextContent(String.valueOf(statusLine.getStatusCode())); reasonEl.setTextContent(statusLine.getReasonPhrase()); // the line as received, not parsed originalEl.setTextContent(statusLine.toString()); return statusLineEl; }
From source file:org.mule.transport.http.HttpResponse.java
public HttpResponse(final StatusLine statusline, final Header[] headers, final InputStream content) throws IOException { super();//from w w w . j a va 2 s.com if (statusline == null) { throw new IllegalArgumentException("Status line may not be null"); } setStatusLine(HttpVersion.parse(statusline.getHttpVersion()), statusline.getStatusCode(), statusline.getReasonPhrase()); setHeaders(headers); if (content != null) { InputStream in = content; Header contentLength = this.headers.getFirstHeader(HttpConstants.HEADER_CONTENT_LENGTH); Header transferEncoding = this.headers.getFirstHeader(HttpConstants.HEADER_TRANSFER_ENCODING); if (transferEncoding != null) { if (transferEncoding.getValue().indexOf(HttpConstants.TRANSFER_ENCODING_CHUNKED) != -1) { in = new ChunkedInputStream(in); } } else if (contentLength != null) { long len = getContentLength(); if (len >= 0) { in = new ContentLengthInputStream(in, len); } } } }
From source file:org.roosster.RoossterTestCase.java
/** * //from ww w. j av a2 s. co m */ public void logMethodResponse(HttpMethod method) throws java.io.IOException { if (method == null) throw new IllegalArgumentException("FAILED: Tried to log 'null' method"); if (method.isRequestSent() == false) throw new IllegalArgumentException("FAILED: Tried to log 'not-sent' method"); System.out.println("++++++++++++++++++++++++ BEGIN HEADER LOGGING ++++++++++++++++++++++++"); StatusLine sline = method.getStatusLine(); System.out.println("\nStatusLine: " + sline.getHttpVersion() + " " + sline.getStatusCode() + " " + sline.getReasonPhrase()); System.out.println("\nHeader:\n"); Header[] headers = method.getResponseHeaders(); for (int i = 0; i < headers.length; i++) { System.out.println(headers[i].toString()); } System.out.println("\nResponseBody:\n" + method.getResponseBodyAsString() + "\n\n"); System.out.println("++++++++++++++++++++++++ END HEADER LOGGING ++++++++++++++++++++++++\n\n"); }