michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0:
michael@0: package org.mozilla.gecko.sync.net;
michael@0:
michael@0: import java.io.IOException;
michael@0: import java.security.GeneralSecurityException;
michael@0:
michael@0: import ch.boye.httpclientandroidlib.HttpResponse;
michael@0: import ch.boye.httpclientandroidlib.client.ClientProtocolException;
michael@0: import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
michael@0: import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
michael@0:
michael@0: /**
michael@0: * ResourceDelegate implementers must ensure that HTTP responses
michael@0: * are fully consumed to ensure that connections are returned to
michael@0: * the pool:
michael@0: *
michael@0: * EntityUtils.consume(entity);
michael@0: * @author rnewman
michael@0: *
michael@0: */
michael@0: public interface ResourceDelegate {
michael@0: // Request augmentation.
michael@0: AuthHeaderProvider getAuthHeaderProvider();
michael@0: void addHeaders(HttpRequestBase request, DefaultHttpClient client);
michael@0:
michael@0: /**
michael@0: * The value of the User-Agent header to include with the request.
michael@0: *
michael@0: * @return User-Agent header value; null means do not set User-Agent header.
michael@0: */
michael@0: public String getUserAgent();
michael@0:
michael@0: // Response handling.
michael@0:
michael@0: /**
michael@0: * Override this to handle an HttpResponse.
michael@0: *
michael@0: * ResourceDelegate implementers must ensure that HTTP responses are
michael@0: * fully consumed to ensure that connections are returned to the pool, for
michael@0: * example by calling EntityUtils.consume(response.getEntity())
.
michael@0: */
michael@0: void handleHttpResponse(HttpResponse response);
michael@0: void handleHttpProtocolException(ClientProtocolException e);
michael@0: void handleHttpIOException(IOException e);
michael@0:
michael@0: // During preparation.
michael@0: void handleTransportException(GeneralSecurityException e);
michael@0:
michael@0: // Connection parameters.
michael@0: int connectionTimeout();
michael@0: int socketTimeout();
michael@0: }