Package org.apache.http.message

Examples of org.apache.http.message.BasicHttpResponse.addHeader()


    public void testMultipleAllows() {
        ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
        BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
        BasicHttpResponse resp = new BasicHttpResponse(line);
        resp.addHeader("Allow", "POST");
        resp.addHeader("Allow", "GET");

        HttpOptions opt = new HttpOptions();
        Set<String> methodsName = opt.getAllowedMethods(resp);
       
View Full Code Here


    public void testMultipleAllows() {
        ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1);
        BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason");
        BasicHttpResponse resp = new BasicHttpResponse(line);
        resp.addHeader("Allow", "POST");
        resp.addHeader("Allow", "GET");

        HttpOptions opt = new HttpOptions();
        Set<String> methodsName = opt.getAllowedMethods(resp);
       
        assertTrue(methodsName.contains("POST"));
View Full Code Here

    public HttpResponse generateResponse() {
        BasicHttpResponse response = new BasicHttpResponse(this.version, this.status,
                EnglishReasonPhraseCatalog.INSTANCE.getReason(this.status, Locale.US));
        if (this.keepAlive) {
            response.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        } else {
            response.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
        }
        response.setEntity(this.entity);
        return response;
View Full Code Here

        BasicHttpResponse response = new BasicHttpResponse(this.version, this.status,
                EnglishReasonPhraseCatalog.INSTANCE.getReason(this.status, Locale.US));
        if (this.keepAlive) {
            response.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        } else {
            response.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
        }
        response.setEntity(this.entity);
        return response;
    }
View Full Code Here

  @Override
  public HttpResponse head() {
    BasicHttpResponse response = new BasicHttpResponse(this.response.getStatusLine());
    Header[] allHeaders = this.response.getAllHeaders();
    for (Header allHeader : allHeaders)
      response.addHeader(allHeader);
    response.setEntity(new ByteArrayEntity(new byte[]{}));
    return response;
  }

  protected void transferFirstHeader(final String headerName, final HttpMessage origin, final HttpMessage dest) {
View Full Code Here

    @Test
    public void testAuthentication() throws Exception {
        final HttpHost host = new HttpHost("somehost", 80);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
View Full Code Here

    @Test
    public void testAuthentication() throws Exception {
        final HttpHost host = new HttpHost("somehost", 80);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        Assert.assertTrue(this.httpAuthenticator.handleAuthChallenge(host,
View Full Code Here

    public void testAuthentication() throws Exception {
        final HttpHost host = new HttpHost("somehost", 80);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"test\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm1\", nonce=\"1234\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        Assert.assertTrue(this.httpAuthenticator.handleAuthChallenge(host,
                response, authStrategy, this.authState, this.context));
View Full Code Here

    @Test
    public void testAuthenticationNoSupportedChallenges() throws Exception {
        final HttpHost host = new HttpHost("somehost", 80);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "This realm=\"test\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "That realm=\"realm1\", nonce=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        Assert.assertFalse(this.httpAuthenticator.handleAuthChallenge(host,
View Full Code Here

    @Test
    public void testAuthenticationNoSupportedChallenges() throws Exception {
        final HttpHost host = new HttpHost("somehost", 80);
        final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "This realm=\"test\""));
        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "That realm=\"realm1\", nonce=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        Assert.assertFalse(this.httpAuthenticator.handleAuthChallenge(host,
                response, authStrategy, this.authState, this.context));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.