playwright-go/network.go
Can Stand d2aa790e89
Some checks failed
Go / Lint (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, windows-latest) (push) Has been cancelled
Go / test-examples (push) Has been cancelled
Docs / Deploy docs (push) Has been cancelled
Verify Types / verify (push) Has been cancelled
Go / finish (push) Has been cancelled
chore: maintain StorageState type (#583)
2026-02-23 09:13:11 -08:00

63 lines
1.3 KiB
Go

package playwright
import (
"strings"
)
type rawHeaders struct {
headersArray []NameValue
headersMap map[string][]string
}
func (r *rawHeaders) Get(name string) string {
values := r.GetAll(name)
if len(values) == 0 {
return ""
}
sep := ", "
if strings.ToLower(name) == "set-cookie" {
sep = "\n"
}
return strings.Join(values, sep)
}
func (r *rawHeaders) GetAll(name string) []string {
name = strings.ToLower(name)
if _, ok := r.headersMap[name]; !ok {
return []string{}
}
return r.headersMap[name]
}
func (r *rawHeaders) Headers() map[string]string {
out := make(map[string]string)
for key := range r.headersMap {
out[key] = r.Get(key)
}
return out
}
func (r *rawHeaders) HeadersArray() []NameValue {
return r.headersArray
}
func newRawHeaders(headers any) *rawHeaders {
r := &rawHeaders{}
r.headersArray = make([]NameValue, 0)
r.headersMap = make(map[string][]string)
for _, header := range headers.([]any) {
entry := header.(map[string]any)
name := entry["name"].(string)
value := entry["value"].(string)
r.headersArray = append(r.headersArray, NameValue{
Name: name,
Value: value,
})
if _, ok := r.headersMap[strings.ToLower(name)]; !ok {
r.headersMap[strings.ToLower(name)] = make([]string, 0)
}
r.headersMap[strings.ToLower(name)] = append(r.headersMap[strings.ToLower(name)], value)
}
return r
}