/*
 *
 * Copyright 2013 Netflix, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/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.
 *
 */
package com.netflix.niws.client.http;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.netflix.client.IPrimeConnection;
import com.netflix.client.config.IClientConfig;
import com.netflix.http4.NFHttpClient;
import com.netflix.http4.NFHttpClientFactory;
import com.netflix.loadbalancer.Server;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.util.EntityUtils;

/**
 * An implementation of {@link IPrimeConnection} using Apache HttpClient.
 * 
 * @author awang
 *
 */
public class HttpPrimeConnection implements IPrimeConnection {

    private static final Logger logger = LoggerFactory.getLogger(HttpPrimeConnection.class);
    
    private NFHttpClient client;
    
    public HttpPrimeConnection() {
    }
    
    @Override
    public boolean connect(Server server, String primeConnectionsURIPath) throws Exception {
        String url = "http://" + server.getHostPort() + primeConnectionsURIPath;
        logger.debug("Trying URL: {}", url);
        HttpUriRequest get = new HttpGet(url);
        HttpResponse response = null;
        try {
            response = client.execute(get);
            String resp = EntityUtils.toString(response.getEntity());
            if (logger.isDebugEnabled()) {
                logger.debug("Response code:" + response.getStatusLine().getStatusCode());
                logger.debug("Response:" + resp);
            }
        } finally {
           get.abort();
        }
        return true;
    }

    @Override
    public void initWithNiwsConfig(IClientConfig niwsClientConfig) {
        client = NFHttpClientFactory.getNamedNFHttpClient(niwsClientConfig.getClientName() + "-PrimeConnsClient"); 
        HttpConnectionParams.setConnectionTimeout(client.getParams(), 2000);        
    }
}

@@ -1100,49 +1100,8 @@
 ams;
-%0Aimport org.apache.http.util.EntityUtils;
 %0A%0A/*
@@ -1830,78 +1830,8 @@
 t);%0A
-            String resp = EntityUtils.toString(response.getEntity());%0A
     
@@ -1964,58 +1964,8 @@
 ));%0A
-                logger.debug(%22Response:%22 + resp);%0A
     

Remove logging of PrimeConnection response body.