mirror of
https://code.dumpstack.io/tools/wi.git
synced 2024-11-13 05:59:19 +02:00
Save response cookies
This commit is contained in:
parent
386c74a10b
commit
f01134eaa4
|
@ -132,6 +132,13 @@ func Get(db *sql.DB, linkUrl string) {
|
|||
|
||||
storage.AddHistoryURL(db, linkUrl)
|
||||
|
||||
if len(resp.Cookies()) != 0 {
|
||||
err = storage.AddCookies(db, lastUrl.Host, resp.Cookies())
|
||||
if err != nil {
|
||||
log.Fatalln("Add cookies:", err)
|
||||
}
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
utf8, err := charset.NewReader(resp.Body, resp.Header.Get("Content-Type"))
|
||||
|
@ -231,6 +238,13 @@ func Form(db *sql.DB, formID int64, formArgs []string) {
|
|||
var status int64
|
||||
fmt.Sscanf(resp.Status, "%d", &status)
|
||||
|
||||
if status < 400 && len(resp.Cookies()) != 0 {
|
||||
err = storage.AddCookies(db, lastUrl.Host, resp.Cookies())
|
||||
if err != nil {
|
||||
log.Fatalln("Add cookies:", err)
|
||||
}
|
||||
}
|
||||
|
||||
if status >= 300 && status < 400 {
|
||||
Get(db, lastUrl.String())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue