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

sap.ai.st.cm.plugins.ciintegration.odataclient.CMOdataHTTPFactory Maven / Gradle / Ivy

The newest version!
package sap.ai.st.cm.plugins.ciintegration.odataclient;

import static java.lang.String.format;

import java.net.URI;
import org.apache.http.client.CookieStore;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
import org.apache.olingo.commons.api.http.HttpMethod;

import com.sap.cmclient.VersionHelper;

/**
 * Our own factory for http clients.
 * We set
 *   
    *
  • We set a cookie store *
  • We set the USER_AGENT header in order to be able to identify requests performed * by the client (and the corresponding client version) on the server side. *
*/ public class CMOdataHTTPFactory extends BasicAuthHttpClientFactory { private final CookieStore cookieStore; public CMOdataHTTPFactory(String username, String password) { super(username, password); this.cookieStore = new BasicCookieStore(); } @Override public DefaultHttpClient create(final HttpMethod method, final URI uri) { final DefaultHttpClient httpClient = super.create(method, uri); httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, format("SAP CM Client/%s based on %s", VersionHelper.getShortVersion(), USER_AGENT)); httpClient.setCookieStore(this.cookieStore); return httpClient; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy