HTTPS를 사용하여 Android에서 웹 페이지를 가져 오는 중입니다 (자체 서명 및 오래된 것임). here - 묻지 않음, 내 서버가 아닙니다 :)).Android에서 HTTPS 페이지 잘림을 가져옵니다.
내가 정의한 내 UnsecureSSLSocketFactory 언급
public class MyHttpClient extends DefaultHttpClient {
public MyHttpClient() {
super();
final HttpParams params = getParams();
HttpConnectionParams.setConnectionTimeout(params,
REGISTRATION_TIMEOUT);
HttpConnectionParams.setSoTimeout(params, REGISTRATION_TIMEOUT);
ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT);
}
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
registry.register(new Scheme("https", new UnsecureSSLSocketFactory(), 443));
return new SingleClientConnManager(getParams(), registry);
}
}
상기
topic에 주어진 제안을 기반으로합니다.
나는 다음 페이지
public class HTTPHelper {
private final static String TAG = "HTTPHelper";
private final static String CHARSET = "ISO-8859-1";
public static final String USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)";
public static final String ACCEPT_CHARSET = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
/**
* Sends an HTTP request
* @param url
* @param post
* @return
*/
public String sendRequest(String url, String post) throws ConnectionException {
MyHttpClient httpclient = new MyHttpClient();
HttpGet httpget = new HttpGet(url);
httpget.addHeader("User-Agent", USER_AGENT);
httpget.addHeader("Accept", ACCEPT);
httpget.addHeader("Accept-Charset", ACCEPT_CHARSET);
HttpResponse response;
try {
response = httpclient.execute(httpget);
} catch (Exception e) {
throw new ConnectionException(e.getMessage());
}
HttpEntity entity = response.getEntity();
try {
pageSource = convertStreamToString(entity.getContent());
} catch (Exception e) {
throw new ConnectionException(e.getMessage());
}
finally {
if (entity != null) {
try {
entity.consumeContent();
} catch (IOException e) {
throw new ConnectionException(e.getMessage());
}
}
}
httpclient.getConnectionManager().shutdown();
return pageSource;
}
/**
* Converts a stream to a string
* @param is
* @return
*/
private static String convertStreamToString(InputStream is)
{
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is, CHARSET));
StringBuilder stringBuilder = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
stringBuilder.append(line + "\n");
}
} catch (IOException e) {
Log.d(TAG, "Exception in convertStreamToString", e);
} finally {
try {
is.close();
} catch (IOException e) {}
}
return stringBuilder.toString();
} catch (Exception e) {
throw new Error("Unsupported charset");
}
}
}
에게 내가 라인에 대한 백 후립니다 얻을 페이지를 fecth이 클래스를 사용하고 있습니다. 그것은 '_'(밑줄) char 뒤에 'r'char가 오는 정확한 지점에서 잘립니다. 이 페이지의 첫 번째 밑줄이 아닙니다.
인코딩 문제 일 수 있다고 생각하여 UTF-8과 ISO-8859-1을 모두 시도했지만 여전히 잘립니다. Firefox에서 페이지를 열면 인코딩이 ISO-8851-1로보고됩니다. 경우 당신이 궁금해하는
, 웹 페이지는 https://ricarichiamoci.dsu.pisa.it/ 이며이 사람이 왜 아이디어가 있습니까
function ChangeOffset(NewOffset) {
document.mainForm.last
대신
function ChangeOffset(NewOffset) {
document.mainForm.last_record.value = NewOffset;
을 있어야 할 곳에, 라인 169에서 잘립니다 페이지가 잘 렸는가?