resty icon indicating copy to clipboard operation
resty copied to clipboard

error cookie domain

Open yuelwish opened this issue 3 years ago • 1 comments

import (
	"github.com/go-resty/resty/v2"
	"net/http"
)

func main() {
	client := resty.New()
	client.SetCookie(&http.Cookie{Name: "Hi", Value: "word", Domain: ".google.com"})
	resp, _ := client.R().Get("http://www.httpbin.org/anything")
	println(resp.String())
}

{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Cookie": "Hi=word", 
    "Host": "www.httpbin.org", 
    "User-Agent": "go-resty/2.6.0 (https://github.com/go-resty/resty)", 
    "X-Amzn-Trace-Id": "Root=1-6087b57d-10e1f3904a5713720a5d73cd"
  }, 
  "json": null, 
  "method": "GET", 
  "origin": "61.165.29.81", 
  "url": "http://www.httpbin.org/anything"
}

When I use client to set up cookie, I should need to determine the domain. of cookie

github.com/go-resty/resty/[email protected]/middleware.go:createHTTPRequest:185

// Add cookies from client instance into http request
for _, cookie := range c.Cookies {
    r.RawRequest.AddCookie(cookie)
}

yuelwish avatar Apr 27 '21 07:04 yuelwish

@yuelwish I'm sorry for the delay response. Could you provide more details? I'm unable to understand the issue.

jeevatkm avatar Oct 01 '23 03:10 jeevatkm