package com.gh4a.loader;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import android.content.Context;

import com.gh4a.feeds.FeedHandler;
import com.gh4a.holder.Feed;

public class FeedLoader extends BaseLoader<List<Feed>> {
    private String mUrl;

    private static final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    
    public FeedLoader(Context context, String url) {
        super(context);
        mUrl = url;
    }

    @Override
    public List<Feed> doLoadInBackground() throws Exception {
        BufferedInputStream bis = null;
        try {
            URL url = new URL(mUrl);
            HttpURLConnection request = (HttpURLConnection) url.openConnection();

            if (request instanceof HttpsURLConnection) {
                ((HttpsURLConnection) request).setHostnameVerifier(DO_NOT_VERIFY);
            }

            request.setRequestMethod("GET");
            request.setDoOutput(true);

            request.connect();
            bis = new BufferedInputStream(request.getInputStream());

            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            FeedHandler handler = new FeedHandler();
            parser.parse(bis, handler);
            return handler.getFeeds();
        }
        finally {
            if (bis != null) {
                try {
                    bis.close();
                }
                catch (IOException e) {
                }
            }
        }
    }
}
@@ -99,33 +99,19 @@
 ava.net.
-HttpURLConnection
+URL
 ;%0Aimport
@@ -115,32 +115,42 @@
 ort java.net.URL
+Connection
 ;%0Aimport java.ut
@@ -1015,20 +1015,16 @@
         
-Http
 URLConne
@@ -1040,20 +1040,16 @@
 uest = (
-Http
 URLConne
@@ -1237,124 +1237,8 @@
  %7D%0A%0A
-            request.setRequestMethod(%22GET%22);%0A            request.setDoOutput(true);%0A%0A            request.connect();%0A
     
@@ -1692,32 +1692,16 @@
        %7D
-%0A               
  catch (

Fix loading of blog items.