me-azharahmed / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Switch to using HttpClient in the MapTileDownloader #212

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
As submitted in Issue 200 (modified to separate from other changes). This patch 
will implement using HttpClient as suggested in 
http://groups.google.com/d/msg/osmdroid/uDK_SUNeyhs/obv4V2w3cZoJ

Please review and add comments.

Original issue reported on code.google.com by kurtzm...@gmail.com on 15 May 2011 at 10:48

Attachments:

GoogleCodeExporter commented 8 years ago
Issue 200 has been merged into this issue.

Original comment by kurtzm...@gmail.com on 15 May 2011 at 11:06

GoogleCodeExporter commented 8 years ago
Looks okay, but I have some questions.

1. What's the difference between NUMBER_OF_TILE_DOWNLOAD_THREADS and 
MAX_HTTP_CONNECTION?
2. Why do you set a fake user agent?
3. Did you copy HttpClientFactory from somewhere? Does it have a license?

Original comment by neilboyd on 17 May 2011 at 9:50

GoogleCodeExporter commented 8 years ago
NUMBER_OF_TILE_DOWNLOAD_THREADS limits the number of fetching threads, so as 
not to block other
MAX_HTTP_CONNECTION is basically useless ;) i forgot to remove
User-Agent is useful when using other maps servers, Bing Ovi etc...
HttpClientFactory copied code from another of my project

HttpClientFactory should look like this

public class HttpClientFactory implements OpenStreetMapTileProviderConstants {

    public static DefaultHttpClient getThreadSafeClient() {
        final SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        final HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        HttpProtocolParams.setUseExpectContinue(params, false);
        final ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, schemeRegistry);
        final DefaultHttpClient mClient = new DefaultHttpClient(manager, params);
        return mClient;
    }

}

Original comment by 828...@gmail.com on 17 May 2011 at 10:58

GoogleCodeExporter commented 8 years ago
Seems a little over-complicated and it's hard for me to say whether that's 
justified, so I'll say it's okay.

@Marc, do you want to commit this since you're the owner?

Original comment by neilboyd on 19 May 2011 at 8:31

GoogleCodeExporter commented 8 years ago
See also issue 273

Original comment by neilboyd on 12 Nov 2011 at 12:32