List of usage examples for org.apache.http.cookie SM COOKIE
String COOKIE
To view the source code for org.apache.http.cookie SM COOKIE.
Click Source Link
From source file:org.droidparts.http.CookieJar.java
@Override public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException { clearExpired(new Date()); ArrayList<String> cookies = new ArrayList<String>(); for (Cookie cookie : getCookies(uri)) { cookies.add(cookie.getName() + "=" + cookie.getValue()); }//ww w.ja va 2 s . c o m return singletonMap(SM.COOKIE, singletonList(join(cookies, SEP, null))); }
From source file:org.zywx.wbpalmstar.engine.EDownloadDialog.java
@Override public void run() { try {/*w w w . j a v a2 s.c om*/ if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { mProgressHandler.sendMessage(mProgressHandler.obtainMessage(-2, "SD?!")); mProgressHandler.sendEmptyMessage(-3); return; } mClient = new URL(url); mConnection = (HttpURLConnection) mClient.openConnection(); mConnection.setRequestMethod("GET"); mConnection.setRequestProperty("Accept-Encoding", "gzip, deflate"); String cookie = getCookie(url); if (null != cookie) { mConnection.setRequestProperty(SM.COOKIE, cookie); } mConnection.setUseCaches(false); mConnection.setRequestProperty("Connection", "Keep-Alive"); mConnection.setRequestProperty("Charset", HTTP.UTF_8); mConnection.setRequestProperty("User-Agent", EBrowserSetting.USERAGENT); mConnection.setReadTimeout(1000 * 30); mConnection.setConnectTimeout(1000 * 30); mConnection.setInstanceFollowRedirects(false); mConnection.connect(); int responseCode = mConnection.getResponseCode(); if (200 == responseCode) { saveToFile(); } else { mProgressHandler.sendMessage(mProgressHandler.obtainMessage(-2, ",?!")); mProgressHandler.sendEmptyMessage(-3); } } catch (Exception e) { e.printStackTrace(); if (!mFromStop) { mProgressHandler.sendMessage(mProgressHandler.obtainMessage(-2, ",?!")); } mProgressHandler.sendEmptyMessage(-3); } }
From source file:com.gargoylesoftware.htmlunit.httpclient.HtmlUnitBrowserCompatCookieSpec.java
@Override public List<Header> formatCookies(final List<Cookie> cookies) { Collections.sort(cookies, COOKIE_COMPARATOR); final CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.size()); buffer.append(SM.COOKIE); buffer.append(": "); for (int i = 0; i < cookies.size(); i++) { final Cookie cookie = cookies.get(i); if (i > 0) { buffer.append("; "); }//from w w w . j av a 2 s .c om final String cookieName = cookie.getName(); final String cookieValue = cookie.getValue(); if (cookie.getVersion() > 0 && !isQuoteEnclosed(cookieValue)) { HtmlUnitBrowserCompatCookieHeaderValueFormatter.INSTANCE.formatHeaderElement(buffer, new BasicHeaderElement(cookieName, cookieValue), false); } else { // Netscape style cookies do not support quoted values buffer.append(cookieName); buffer.append("="); if (cookieValue != null) { buffer.append(cookieValue); } } } final List<Header> headers = new ArrayList<>(1); headers.add(new BufferedHeader(buffer)); return headers; }
From source file:org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver.java
private Bitmap getIconBitmap(Context context, String iconUrl) { try {//from w w w.j av a 2 s . co m URL uRL = new URL(iconUrl); HttpURLConnection connection = (HttpURLConnection) uRL.openConnection(); String cookie = CookieManager.getInstance().getCookie(iconUrl); if (null != cookie) { connection.setRequestProperty(SM.COOKIE, cookie); } connection.connect(); if (200 == connection.getResponseCode()) { InputStream input = connection.getInputStream(); if (input != null) { Environment.getDownloadCacheDirectory(); File ecd = context.getExternalCacheDir(); File file = new File(ecd, "pushIcon.png"); OutputStream outStream = new FileOutputStream(file); byte buf[] = new byte[8 * 1024]; while (true) { int numread = input.read(buf); if (numread == -1) { break; } outStream.write(buf, 0, numread); } Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); return bitmap; } } } catch (Exception e) { e.printStackTrace(); } return null; }