mobile/android/base/sync/net/ResourceDelegate.java

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:1b73f6a52db2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.gecko.sync.net;
6
7 import java.io.IOException;
8 import java.security.GeneralSecurityException;
9
10 import ch.boye.httpclientandroidlib.HttpResponse;
11 import ch.boye.httpclientandroidlib.client.ClientProtocolException;
12 import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
13 import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
14
15 /**
16 * ResourceDelegate implementers must ensure that HTTP responses
17 * are fully consumed to ensure that connections are returned to
18 * the pool:
19 *
20 * EntityUtils.consume(entity);
21 * @author rnewman
22 *
23 */
24 public interface ResourceDelegate {
25 // Request augmentation.
26 AuthHeaderProvider getAuthHeaderProvider();
27 void addHeaders(HttpRequestBase request, DefaultHttpClient client);
28
29 /**
30 * The value of the User-Agent header to include with the request.
31 *
32 * @return User-Agent header value; null means do not set User-Agent header.
33 */
34 public String getUserAgent();
35
36 // Response handling.
37
38 /**
39 * Override this to handle an HttpResponse.
40 *
41 * ResourceDelegate implementers <b>must</b> ensure that HTTP responses are
42 * fully consumed to ensure that connections are returned to the pool, for
43 * example by calling <code>EntityUtils.consume(response.getEntity())</code>.
44 */
45 void handleHttpResponse(HttpResponse response);
46 void handleHttpProtocolException(ClientProtocolException e);
47 void handleHttpIOException(IOException e);
48
49 // During preparation.
50 void handleTransportException(GeneralSecurityException e);
51
52 // Connection parameters.
53 int connectionTimeout();
54 int socketTimeout();
55 }

mercurial