Package org.apache.http

Examples of org.apache.http.StatusLine


    }

    public static HttpCacheEntry makeCacheEntry(final Date requestDate,
            final Date responseDate, final Header[] headers, final byte[] bytes,
            final Map<String,String> variantMap) {
        final StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        return new HttpCacheEntry(requestDate, responseDate, statusLine, headers, new HeapResource(bytes), variantMap);
    }
View Full Code Here


            httpget.getParams().setParameter("http.socket.timeout", new Integer(timeout));

            // Execute HTTP request
            HttpResponse response = client.execute(httpget);

            StatusLine status = response.getStatusLine();
            if (status.getStatusCode() != HttpStatus.SC_OK) {
                if (!ignoreErrors) {
                    throw new MojoExecutionException(status.getStatusCode() + ": " + status.getReasonPhrase());
                }
                getLog().error(status.getStatusCode() + ": " + status.getReasonPhrase());
                return;
            }
            Header header = response.getFirstHeader("junit.errors");
            errors = header == null ? 0 : Integer.parseInt(header.getValue());
            header = response.getFirstHeader("junit.failures");
View Full Code Here

           
            res.sampleEnd(); // Done with the sampling proper.
            currentRequest = null;

            // Now collect the results into the HTTPSampleResult:
            StatusLine statusLine = httpResponse.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            res.setResponseCode(Integer.toString(statusCode));
            res.setResponseMessage(statusLine.getReasonPhrase());
            res.setSuccessful(isSuccessCode(statusCode));

            res.setResponseHeaders(getResponseHeaders(httpResponse));
            if (res.isRedirect()) {
                final Header headerLocation = httpResponse.getLastHeader(HTTPConstants.HEADER_LOCATION);
View Full Code Here

           
            res.sampleEnd(); // Done with the sampling proper.
            currentRequest = null;

            // Now collect the results into the HTTPSampleResult:
            StatusLine statusLine = httpResponse.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            res.setResponseCode(Integer.toString(statusCode));
            res.setResponseMessage(statusLine.getReasonPhrase());
            res.setSuccessful(isSuccessCode(statusCode));

            res.setResponseHeaders(getResponseHeaders(httpResponse));
            if (res.isRedirect()) {
                final Header headerLocation = httpResponse.getLastHeader(HEADER_LOCATION);
View Full Code Here

   * @throws java.io.IOException if validation failed
   */
  protected void validateResponse(HttpInvokerClientConfiguration config, HttpResponse response)
      throws IOException {

    StatusLine status = response.getStatusLine();
    if (status.getStatusCode() >= 300) {
      throw new NoHttpResponseException(
          "Did not receive successful HTTP response: status code = " + status.getStatusCode() +
          ", status message = [" + status.getReasonPhrase() + "]");
    }
  }
View Full Code Here

   * @throws java.io.IOException if validation failed
   */
  protected void validateResponse(HttpInvokerClientConfiguration config, HttpResponse response)
      throws IOException {

    StatusLine status = response.getStatusLine();
    if (status.getStatusCode() >= 300) {
      throw new NoHttpResponseException(
          "Did not receive successful HTTP response: status code = " + status.getStatusCode() +
          ", status message = [" + status.getReasonPhrase() + "]");
    }
  }
View Full Code Here

    {
      request = buildRequest(query, url.getProtocol(), url.getHost(), url.getPort(), url.getPath());

      final HttpResponse response = execute(request);

      final StatusLine status = response.getStatusLine();

      final String responseBody = extractStringFrom(response);

      ensureResponse(status.getStatusCode() == HttpStatus.SC_OK,
          format("Server responded with %s to request %s", responseBody, request.getURI()),
          status.getStatusCode(), status.getReasonPhrase());

      return responseBody;
    }
    catch (final RuntimeException anyException)
    {
View Full Code Here

   * @return the string
   */
  private static String extractStringFrom(final HttpResponse response)
  {
    final HttpEntity entity = response.getEntity();
    final StatusLine status = response.getStatusLine();
    InputStream stream = null;

    ensureResponse(contentSizeIsValid(entity),
        format("Response content has unexpected length [%s]", entity.getContentLength()),
        status.getStatusCode(), status.getReasonPhrase());

    try
    {
      stream = entity.getContent();
    }
    catch (final Exception exception)
    {
      throw new ResponseException("Error while opening response stream", status.getStatusCode(),
          status.getReasonPhrase(), exception);
    }

    return readStringFrom(stream, ifFailureThenReportAbout(status));
  }
View Full Code Here

        this.responseFactory = responseFactory;
    }

    protected HttpMessage createMessage(final CharArrayBuffer buffer)
            throws HttpException {
        StatusLine statusline = BasicStatusLine.parse(buffer, 0, buffer.length());
        return this.responseFactory.newHttpResponse(statusline, null);
    }
View Full Code Here

     */
    private final static HttpResponse createResponse(HttpVersion version,
                                                     int status,
                                                     String message) {

        StatusLine statusline = new BasicStatusLine(version, status, message);
        HttpResponse response = new BasicHttpResponse(statusline);

        return response;

    } // createResponse/empty
View Full Code Here

TOP

Related Classes of org.apache.http.StatusLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.