forked from github/szkolny
Remove unnecessary files.
This commit is contained in:
parent
b7191c938f
commit
cd3b69b136
@ -1,47 +0,0 @@
|
||||
package pl.szczodrzynski.edziennik.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.koushikdutta.async.http.Headers;
|
||||
import com.koushikdutta.ion.Ion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.CookieManager;
|
||||
import java.net.URI;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IonCookieManager {
|
||||
private static final String TAG = "IonCookieManager";
|
||||
private CookieManager manager;
|
||||
|
||||
public IonCookieManager(Context context) {
|
||||
Ion ion = Ion.getDefault(context);
|
||||
manager = ion.getCookieMiddleware().getCookieManager();
|
||||
}
|
||||
|
||||
public void storeCookies(URLConnection conn) throws IOException {
|
||||
List<String> cookies = conn.getHeaderFields().get("Set-Cookie");
|
||||
URI uri = URI.create(conn.getURL().toString());
|
||||
if(cookies != null) {
|
||||
storeCookies(uri, cookies);
|
||||
}
|
||||
}
|
||||
|
||||
public void storeCookies(URI uri, List<String> cookies) throws IOException {
|
||||
Headers headers = new Headers();
|
||||
headers.addAll("Set-Cookie", cookies);
|
||||
Log.d(TAG, "storeAllCookies: "+cookies.toString());
|
||||
manager.put(uri, headers.getMultiMap());
|
||||
}
|
||||
|
||||
public void storeCookie(URI uri, String cookieName, String cookieValue) throws IOException {
|
||||
List<String> cookie = new ArrayList<String>();
|
||||
cookie.add(String.format("%s=%s", cookieName, cookieValue));
|
||||
Log.d(TAG, "storeCookie: "+String.format("%s=%s", cookieName, cookieValue));
|
||||
storeCookies(uri, cookie);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user