package com.dybweather.app.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpUtil {

	public static void sendHttpRequest(final String address, final HttpCallbackListener listener){
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				HttpURLConnection connection = null;
				try {
					URL url = new URL(address);
					connection = (HttpURLConnection)url.openConnection();
					connection.setRequestMethod("GET");
					connection.setConnectTimeout(60000);
					connection.setReadTimeout(60000);
					InputStream in = connection.getInputStream();
					BufferedReader reader = new BufferedReader(new InputStreamReader(in));
					StringBuilder response = new StringBuilder();
					String line = "";
					while((line = reader.readLine()) != null ){
						response.append(line);
					}
					if(listener != null){
						//صonFinish()
						listener.onFinish(response.toString());
					}
				} catch(Exception e){
					if(listener != null){
						//صonError()
						listener.onError(e);
					} else {
						e.printStackTrace();
					}
				} finally {
					if(connection != null){
						connection.disconnect();
					}
				}
			}
		}).start();
	}
}

@@ -177,16 +177,42 @@
 t.URL;%0A%0A
+import android.util.Log;%0A%0A
 public c
@@ -658,24 +658,135 @@
 out(60000);%0A
+%09%09%09%09%09Log.d(%22HttpUtil%22, connection.getResponseCode() + %22 ,responseMessage:%22 + connection.getResponseMessage());%0A
 %09%09%09%09%09InputSt
@@ -974,16 +974,22 @@
 e = %22%22;%0A
+%09%09%09%09%09%0A
 %09%09%09%09%09whi
@@ -1029,12 +1029,93 @@
 null
- 
 )
+%7B%0A%09%09%09%09%09%09if(line.startsWith(%22%3C%22))%7B%0A%09%09%09%09%09%09%09throw new Exception(%22%D2%B3%DE%B7%22);%0A%09%09%09%09%09%09%7D else 
 %7B%0A
+%09
 %09%09%09%09
@@ -1140,25 +1140,98 @@
 line);%0A%09%09%09%09%09
-%7D
+%09%7D%0A%09%09%09%09%09%7D%0A%09%09%09%09%09//Log.d(%22HttpUtil%22, %22result====%3E: %22 + response.toString());
 %0A%09%09%09%09%09if(lis

解决网页无法访问的bug。