Re: [go-nuts] Query regarding net/http/cookiejar: Cookies() method and Expiry/MaxAge

2022-07-01 Thread Amit Saha
On Thu, Jun 30, 2022 at 8:45 AM 'Sean Liao' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Implement your own cookie jar,
>
> See also:
> https://github.com/golang/go/issues/19291#issuecomment-282576908
>

Thank you. From the issue comment, I don't quite understand this:

>  If the other fields are returned, than these  cookies would trigger
Set-Cookie headers in package http.

Not a question for you - unless of course you know the answer. But I am
thinking out loud as follows:

CookieJar (client) with cookies with all other fields set -> calls a HTTP
server -> Reads the cookies -> Set-Cookie header flow triggered? (?? -> not
quite sure)




> - sean
>
>
> On Wed, Jun 29, 2022 at 11:31 PM Amit Saha  wrote:
>
>> Hi all,
>>
>> Currently the Cookies() method as explained at
>> https://pkg.go.dev/net/http/cookiejar#Jar.Cookies only adds the Name and
>> Value of the cookies and strips out the MaxAge and Expires field (and all
>> other fields). Presumably, as I can see in the code, the logic is if a
>> cookie is returned as a return value from this method, that means, the
>> cookie is valid  - expiry date is in the future, for example.
>>
>> In the context of testing my HTTP handler, I wanted to make sure that the
>> expiry of a certain cookie is set to a specific time in the future.
>>
>> However, the above implementation doesn't make it possible. Is that a
>> fair expectation to have that the cookiejar's Cookies() method will
>> preserve the Expires/MaxAge field of the cookie so that I can verify my
>> HTTP handler function logic? Or is there another alternative suggestion?
>>
>> Thanks,
>> Amit.
>>
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/CANODV3%3D6jUAAsKSkJ3iz5t3U6NH2EDSq0jRG02gmPBYd46Afew%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/PTmjlCkjmU4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CAGabyPrVu4%3DC_KLvC_DkQpuw4KSkSSryUagdD1jZ05Ufa8WRoQ%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3k1W0xTgqTfeTFVcFhqxn9M5z_Rt7wBqu6FLtvrfwZU%2Bw%40mail.gmail.com.


Re: [go-nuts] Query regarding net/http/cookiejar: Cookies() method and Expiry/MaxAge

2022-06-29 Thread 'Sean Liao' via golang-nuts
Implement your own cookie jar,

See also:
https://github.com/golang/go/issues/19291#issuecomment-282576908

- sean


On Wed, Jun 29, 2022 at 11:31 PM Amit Saha  wrote:

> Hi all,
>
> Currently the Cookies() method as explained at
> https://pkg.go.dev/net/http/cookiejar#Jar.Cookies only adds the Name and
> Value of the cookies and strips out the MaxAge and Expires field (and all
> other fields). Presumably, as I can see in the code, the logic is if a
> cookie is returned as a return value from this method, that means, the
> cookie is valid  - expiry date is in the future, for example.
>
> In the context of testing my HTTP handler, I wanted to make sure that the
> expiry of a certain cookie is set to a specific time in the future.
>
> However, the above implementation doesn't make it possible. Is that a fair
> expectation to have that the cookiejar's Cookies() method will preserve the
> Expires/MaxAge field of the cookie so that I can verify my HTTP handler
> function logic? Or is there another alternative suggestion?
>
> Thanks,
> Amit.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CANODV3%3D6jUAAsKSkJ3iz5t3U6NH2EDSq0jRG02gmPBYd46Afew%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPrVu4%3DC_KLvC_DkQpuw4KSkSSryUagdD1jZ05Ufa8WRoQ%40mail.gmail.com.


[go-nuts] Query regarding net/http/cookiejar: Cookies() method and Expiry/MaxAge

2022-06-29 Thread Amit Saha
Hi all,

Currently the Cookies() method as explained at
https://pkg.go.dev/net/http/cookiejar#Jar.Cookies only adds the Name and
Value of the cookies and strips out the MaxAge and Expires field (and all
other fields). Presumably, as I can see in the code, the logic is if a
cookie is returned as a return value from this method, that means, the
cookie is valid  - expiry date is in the future, for example.

In the context of testing my HTTP handler, I wanted to make sure that the
expiry of a certain cookie is set to a specific time in the future.

However, the above implementation doesn't make it possible. Is that a fair
expectation to have that the cookiejar's Cookies() method will preserve the
Expires/MaxAge field of the cookie so that I can verify my HTTP handler
function logic? Or is there another alternative suggestion?

Thanks,
Amit.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3%3D6jUAAsKSkJ3iz5t3U6NH2EDSq0jRG02gmPBYd46Afew%40mail.gmail.com.