-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug and added changes regarding updatng cookie store in Simpl…
…eHttpFetcher
- Loading branch information
1 parent
c59d95d
commit 434f25e
Showing
4 changed files
with
99 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/focusedCrawler/crawler/async/cookieHandler/CookieUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package focusedCrawler.crawler.async.cookieHandler; | ||
|
||
import java.util.Date; | ||
|
||
import org.apache.http.impl.cookie.BasicClientCookie; | ||
|
||
import okhttp3.Cookie.Builder; | ||
|
||
public class CookieUtils { | ||
|
||
public static okhttp3.Cookie getOkkHttpCookie(Cookie cookie) { | ||
Builder builder = new Builder(); | ||
builder.name(cookie.getName()); | ||
builder.value(cookie.getValue()); | ||
builder.expiresAt(cookie.getExpiresAt()); | ||
builder.domain(cookie.getDomain()); | ||
builder.path(cookie.getPath()); | ||
if (cookie.isSecure()) { | ||
builder.secure(); | ||
} | ||
if (cookie.isHttpOnly()) { | ||
builder.httpOnly(); | ||
} | ||
okhttp3.Cookie okkHttpCookie = builder.build(); | ||
return okkHttpCookie; | ||
} | ||
|
||
public static org.apache.http.cookie.Cookie getApacheCookie(Cookie cookie) { | ||
BasicClientCookie apacheCookie = new BasicClientCookie(cookie.getName(), cookie.getValue()); | ||
apacheCookie.setDomain(cookie.getDomain()); | ||
apacheCookie.setExpiryDate(new Date(cookie.getExpiresAt())); | ||
apacheCookie.setPath(cookie.getPath()); | ||
apacheCookie.setSecure(cookie.isSecure()); | ||
return apacheCookie; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters