mirror of
https://github.com/playwright-community/playwright-go.git
synced 2026-06-03 21:02:27 +08:00
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
63 lines
1.3 KiB
Go
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
|
|
}
|