use of com.firenio.codec.http11.Cookie in project ServiceStack.Java by ServiceStack.
the class JavaNetCookieJar method saveFromResponse.
@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
if (cookieHandler != null) {
List<String> cookieStrings = new ArrayList<>();
for (Cookie cookie : cookies) {
cookieStrings.add(cookie.toString());
}
Map<String, List<String>> multimap = Collections.singletonMap("Set-Cookie", cookieStrings);
try {
cookieHandler.put(url.uri(), multimap);
} catch (IOException e) {
Platform.get().log(WARN, "Saving cookies failed for " + url.resolve("/..."), e);
}
}
}
use of com.firenio.codec.http11.Cookie in project 91Pop by DanteAndroid.
the class SharedPrefsCookiePersistor method removeAll.
@Override
public void removeAll(Collection<Cookie> cookies) {
SharedPreferences.Editor editor = sharedPreferences.edit();
for (Cookie cookie : cookies) {
editor.remove(createCookieKey(cookie));
}
editor.apply();
}
use of com.firenio.codec.http11.Cookie in project MusicLake by caiyonglong.
the class PersistentCookieStore method decodeCookie.
/**
* 将字符串反序列化成cookies
*
* @param cookieString cookies string
* @return cookie object
*/
protected Cookie decodeCookie(String cookieString) {
byte[] bytes = hexStringToByteArray(cookieString);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
try {
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((OkHttpCookies) objectInputStream.readObject()).getCookies();
} catch (IOException e) {
Log.d(LOG_TAG, "IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Log.d(LOG_TAG, "ClassNotFoundException in decodeCookie", e);
}
return cookie;
}
use of com.firenio.codec.http11.Cookie in project actframework by actframework.
the class CSRFTest method retrieveCsrfToken.
public List<Cookie> retrieveCsrfToken($.Var<String> csrf) throws IOException {
url("/csrf");
List<Cookie> cookies = cookies();
List<Cookie> returnCookies = C.newList();
for (Cookie cookie : cookies) {
if ("act-xsrf-token".equals(cookie.name())) {
csrf.set(cookie.value());
} else {
returnCookies.add(cookie);
}
}
return returnCookies;
}
use of com.firenio.codec.http11.Cookie in project OkHttp3 by MrZhousf.
the class SerializableCookie method decode.
public Cookie decode(String encodedCookie) {
byte[] bytes = hexStringToByteArray(encodedCookie);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Cookie cookie = null;
ObjectInputStream objectInputStream = null;
try {
objectInputStream = new ObjectInputStream(byteArrayInputStream);
cookie = ((SerializableCookie) objectInputStream.readObject()).cookie;
} catch (IOException e) {
Log.d(TAG, "IOException in decodeCookie", e);
} catch (ClassNotFoundException e) {
Log.d(TAG, "ClassNotFoundException in decodeCookie", e);
} finally {
if (objectInputStream != null) {
try {
objectInputStream.close();
} catch (IOException e) {
Log.d(TAG, "Stream not closed in decodeCookie", e);
}
}
}
return cookie;
}
Aggregations