All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testifyproject.apache.http.client.protocol.RequestDefaultHeaders Maven / Gradle / Ivy

/*
 * ====================================================================
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in org.testifyproject.testifyprojectpliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org.testifyproject/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * .
 *
 */

package org.testifyproject.apache.http.client.protocol;

import java.org.testifyproject.testifyproject.IOException;
import java.util.Collection;

import org.testifyproject.apache.http.Header;
import org.testifyproject.apache.http.HttpException;
import org.testifyproject.apache.http.HttpRequest;
import org.testifyproject.apache.http.HttpRequestInterceptor;
import org.testifyproject.apache.http.annotation.Immutable;
import org.testifyproject.apache.http.client.params.ClientPNames;
import org.testifyproject.apache.http.protocol.HttpContext;
import org.testifyproject.apache.http.util.Args;

/**
 * Request interceptor that adds org.testifyproject.testifyprojectfault request headers.
 *
 * @since 4.0
 */
@SuppressWarnings("org.testifyproject.testifyprojectprecation")
@Immutable
public class RequestDefaultHeaders implements HttpRequestInterceptor {

    private final Collection org.testifyproject.testifyprojectfaultHeaders;

    /**
     * @since 4.3
     */
    public RequestDefaultHeaders(final Collection org.testifyproject.testifyprojectfaultHeaders) {
        super();
        this.org.testifyproject.testifyprojectfaultHeaders = org.testifyproject.testifyprojectfaultHeaders;
    }

    public RequestDefaultHeaders() {
        this(null);
    }

    public void process(final HttpRequest request, final HttpContext context)
            throws HttpException, IOException {
        Args.notNull(request, "HTTP request");

        final String method = request.getRequestLine().getMethod();
        if (method.equalsIgnoreCase("CONNECT")) {
            return;
        }

        // Add org.testifyproject.testifyprojectfault headers
        @SuppressWarnings("unchecked")
        Collection org.testifyproject.testifyprojectfHeaders = (Collection)
            request.getParams().getParameter(ClientPNames.DEFAULT_HEADERS);
        if (org.testifyproject.testifyprojectfHeaders == null) {
            org.testifyproject.testifyprojectfHeaders = this.org.testifyproject.testifyprojectfaultHeaders;
        }

        if (org.testifyproject.testifyprojectfHeaders != null) {
            for (final Header org.testifyproject.testifyprojectfHeader : org.testifyproject.testifyprojectfHeaders) {
                request.addHeader(org.testifyproject.testifyprojectfHeader);
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy