mirror of
https://github.com/ssep1ol/overleaf-registration-be.git
synced 2026-07-21 20:40:21 +00:00
First commit
This commit is contained in:
12
overleaf.go
12
overleaf.go
@@ -20,10 +20,9 @@ type Overleaf struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewOverleaf(baseURL string) *Overleaf {
|
func NewOverleaf(baseURL string) *Overleaf {
|
||||||
// Create a new HTTP client with a cookie jar
|
jar, _ := cookiejar.New(nil) // Create a cookie jar to store cookies
|
||||||
jar, _ := cookiejar.New(nil)
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Jar: jar,
|
Jar: jar, // Attach the cookie jar to the client
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Overleaf{
|
return &Overleaf{
|
||||||
@@ -60,12 +59,7 @@ func (o *Overleaf) post(endpoint string, data map[string]string) (*http.Response
|
|||||||
// Log cookies for debugging
|
// Log cookies for debugging
|
||||||
cookies := o.Client.Jar.Cookies(req.URL)
|
cookies := o.Client.Jar.Cookies(req.URL)
|
||||||
for _, cookie := range cookies {
|
for _, cookie := range cookies {
|
||||||
log.Printf("Cookie sent: %s=%s", cookie.Name, cookie.Value)
|
log.Printf("Cookie sent to %s: %s=%s", endpoint, cookie.Name, cookie.Value)
|
||||||
}
|
|
||||||
|
|
||||||
// Include cookies in the request
|
|
||||||
for _, cookie := range cookies {
|
|
||||||
req.AddCookie(cookie)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return o.Client.Do(req)
|
return o.Client.Do(req)
|
||||||
|
|||||||
Reference in New Issue
Block a user