本文整理匯總了Java中org.apache.http.impl.client.DefaultHttpClient.setCookieStore方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultHttpClient.setCookieStore方法的具體用法?Java DefaultHttpClient.setCookieStore怎麽用?Java DefaultHttpClient.setCookieStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.impl.client.DefaultHttpClient
的用法示例。
在下文中一共展示了DefaultHttpClient.setCookieStore方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: requery
import org.apache.http.impl.client.DefaultHttpClient; //導入方法依賴的package包/類
public static void requery(String tableName,Class clazz,String key) throws ClientProtocolException, IOException, JSONException,Exception {
Log.i(TAG,"Got key " + key + " but couldn't find related parent tr, requerying ...");
String url=FLOWZR_API_URL + nsString + "/key/?tableName=" + DatabaseHelper.TRANSACTION_TABLE + "&key=" + key;
StringBuilder builder = new StringBuilder();
DefaultHttpClient http_client2= new DefaultHttpClient();
http_client2.setCookieStore(http_client.getCookieStore());
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = http_client2.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
InputStream content = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
JSONObject o = new JSONObject(builder.toString()).getJSONArray(DatabaseHelper.TRANSACTION_TABLE).getJSONObject(0);
saveEntityFromJson(o, tableName, clazz,1);
}
示例2: create
import org.apache.http.impl.client.DefaultHttpClient; //導入方法依賴的package包/類
@Override
public DefaultHttpClient create(final HttpMethod method, final URI uri) {
final DefaultHttpClient httpClient = super.create(method, uri);
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
format("SAP CM Client/%s based on %s", CMODataClient.getShortVersion(), USER_AGENT));
httpClient.setCookieStore(this.cookieStore);
return httpClient;
}