cookiejar.go — fiber Source File
Architecture documentation for cookiejar.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1f636fe9_2e71_d567_5a28_0ab4e08b68c5["cookiejar.go"] c0b86961_3ef1_0168_52fc_98627566ed27["bytes"] 1f636fe9_2e71_d567_5a28_0ab4e08b68c5 --> c0b86961_3ef1_0168_52fc_98627566ed27 style 1f636fe9_2e71_d567_5a28_0ab4e08b68c5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// The code was originally taken from https://github.com/valyala/fasthttp/pull/526.
package client
import (
"bytes"
"net"
"strings"
"sync"
"time"
"github.com/gofiber/utils/v2"
"github.com/valyala/fasthttp"
)
var cookieJarPool = sync.Pool{
New: func() any {
return &CookieJar{}
},
}
// AcquireCookieJar returns an empty CookieJar object from the pool.
func AcquireCookieJar() *CookieJar {
jar, ok := cookieJarPool.Get().(*CookieJar)
if !ok {
panic(errCookieJarTypeAssertion)
}
return jar
}
// ReleaseCookieJar returns a CookieJar object to the pool.
func ReleaseCookieJar(c *CookieJar) {
c.Release()
cookieJarPool.Put(c)
}
// CookieJar manages cookie storage for the client. It stores cookies keyed by host.
type CookieJar struct {
hostCookies map[string][]*fasthttp.Cookie
mu sync.Mutex
}
// Get returns all cookies stored for a given URI. If there are no cookies for the
// provided host, the returned slice will be nil.
//
// The CookieJar keeps its own copies of cookies, so it is safe to release the returned
// cookies after use.
func (cj *CookieJar) Get(uri *fasthttp.URI) []*fasthttp.Cookie {
if uri == nil {
return nil
}
secure := bytes.Equal(uri.Scheme(), httpsScheme)
return cj.getByHostAndPath(uri.Host(), uri.Path(), secure)
}
// getByHostAndPath returns cookies stored for a specific host and path.
func (cj *CookieJar) getByHostAndPath(host, path []byte, secure bool) []*fasthttp.Cookie {
if cj.hostCookies == nil {
return nil
// ... (273 more lines)
Domain
Subdomains
Classes
Dependencies
- bytes
Source
Frequently Asked Questions
What does cookiejar.go do?
cookiejar.go is a source file in the fiber codebase, written in go. It belongs to the FiberClient domain, Hooks subdomain.
What functions are defined in cookiejar.go?
cookiejar.go defines 5 function(s): AcquireCookieJar, ReleaseCookieJar, domainMatch, pathMatch, searchCookieByKeyAndPath.
What does cookiejar.go depend on?
cookiejar.go imports 1 module(s): bytes.
Where is cookiejar.go in the architecture?
cookiejar.go is located at client/cookiejar.go (domain: FiberClient, subdomain: Hooks, directory: client).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free