Compare commits

..

2 Commits

Author SHA1 Message Date
bel
7cd5e5467f Merge branch 'master' of http://gogs.scratch.com:59515/bel/truckstop 2022-01-27 16:35:08 -07:00
bel
4f27976fbb log because i think i deploy bad 2022-01-27 16:05:17 -07:00
3 changed files with 6 additions and 13 deletions

View File

@@ -42,14 +42,9 @@ func _do(db storage.DB, r *http.Request) (*http.Response, error) {
logtr.Errorf("failed to get cookies: %v", err) logtr.Errorf("failed to get cookies: %v", err)
} else { } else {
logtr.Verbosef("got cookies for %s: %+v", cookieJarKey, cookies) logtr.Verbosef("got cookies for %s: %+v", cookieJarKey, cookies)
cookieV := strings.Join(r.Header["Cookie"], "; ")
for _, cookie := range cookies { for _, cookie := range cookies {
if len(cookieV) > 0 { r.Header.Add("Cookie", cookie)
cookieV += "; "
}
cookieV += cookie
} }
r.Header.Set("Cookie", cookieV)
} }
logtr.Verbosef("_do: %+v", r) logtr.Verbosef("_do: %+v", r)
resp, err := client.Do(r) resp, err := client.Do(r)
@@ -80,15 +75,13 @@ func setCookies(db storage.DB, host string, resp *http.Response) error {
continue continue
} }
name := strings.Split(value, "=")[0] name := strings.Split(value, "=")[0]
value := strings.Split(value, ";")[0]
nameValues = append(nameValues, [2]string{name, value}) nameValues = append(nameValues, [2]string{name, value})
} }
for _, cookie := range resp.Header["Set-Cookie"] { for _, value := range resp.Header["Set-Cookie"] {
if len(cookie) == 0 { if len(value) == 0 {
continue continue
} }
name := strings.Split(cookie, "=")[0] name := strings.Split(value, "=")[0]
value := strings.Split(cookie, ";")[0]
found := false found := false
for i := range nameValues { for i := range nameValues {
if nameValues[i][0] == name { if nameValues[i][0] == name {

View File

@@ -32,9 +32,9 @@ func TestDoCookies(t *testing.T) {
if calls != 1 { if calls != 1 {
if !strings.Contains(fmt.Sprint(r.Header["Cookie"]), "name=value"+strconv.Itoa(calls-1)) { if !strings.Contains(fmt.Sprint(r.Header["Cookie"]), "name=value"+strconv.Itoa(calls-1)) {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
t.Error("cookie not set as latest: " + fmt.Sprint(r.Header["Cookie"])) t.Error("cookie not set as latest")
} }
if strings.Contains(fmt.Sprint(r.Header["Cookie"]), "Expires") { if !strings.Contains(fmt.Sprint(r.Header["Cookie"]), "Expires") {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
t.Error("cookie not expiration: ", r.Header["Cookie"]) t.Error("cookie not expiration: ", r.Header["Cookie"])
} }

BIN
broker/exec-truckstop Normal file

Binary file not shown.