-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented possibility to get and set all cookies from and to a cook…
…iejar;
- Loading branch information
1 parent
1b6c4cf
commit 39320ce
Showing
8 changed files
with
270 additions
and
61 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package tls_client_cffi_src | ||
|
||
import ( | ||
"fmt" | ||
http "github.com/bogdanfinn/fhttp" | ||
) | ||
|
||
func BuildCookies(cookies []Cookie) []*http.Cookie { | ||
var ret []*http.Cookie | ||
|
||
for _, cookie := range cookies { | ||
ret = append(ret, &http.Cookie{ | ||
Name: cookie.Name, | ||
Value: cookie.Value, | ||
Path: cookie.Path, | ||
Domain: cookie.Domain, | ||
Expires: cookie.Expires.Time, | ||
}) | ||
} | ||
|
||
return ret | ||
} | ||
|
||
func ToCookieMap(cookies []*http.Cookie) map[string][]*http.Cookie { | ||
ret := make(map[string][]*http.Cookie) | ||
|
||
for _, cookie := range cookies { | ||
urlString := fmt.Sprintf("%s%s", cookie.Domain, cookie.Path) | ||
|
||
ret[urlString] = append(ret[urlString], cookie) | ||
} | ||
|
||
return ret | ||
} | ||
|
||
func ToCookieSlice(cookies map[string][]*http.Cookie) []*http.Cookie { | ||
var ret []*http.Cookie | ||
|
||
for _, cookies := range cookies { | ||
ret = append(ret, cookies...) | ||
} | ||
|
||
return ret | ||
} | ||
|
||
func TransformCookies(cookies []*http.Cookie) []Cookie { | ||
var ret []Cookie | ||
|
||
for _, cookie := range cookies { | ||
ret = append(ret, Cookie{ | ||
Name: cookie.Name, | ||
Value: cookie.Value, | ||
Path: cookie.Path, | ||
Domain: cookie.Domain, | ||
Expires: Timestamp{ | ||
Time: cookie.Expires, | ||
}, | ||
}) | ||
} | ||
|
||
return ret | ||
} |
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
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
Oops, something went wrong.