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

2022-06-29 Thread Volker Dobler
On Thursday, 30 June 2022 at 00:31:29 UTC+2 amits wrote:

> 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.
>
Technically neither is "stripped out", the Jar itself knows about these
fields, they just aren't returned to the caller of Cookies().
 

> 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.
>
That can be done without putting the cookies into a Jar:
Just inspect the raw cookies sent in the Request, e.g. with
net/http.Request.Cookies. These cookies have all fields set.
 

> 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? 
>
Are you asking whether it's a fair to expect that
net/http/cookiejar.Jar doesn't have bugs? It has a decent
set of tests that check expiry of cookies so I think yes,
this is a fair expectation.
 

> Or is there another alternative suggestion?
>
There are open source drop in replacements for
net/http/cookiejar.Jar that allow deep inspection of their
content, but I really doubt that this is needed.

There are two questions:
1) Do your cookies have the right MaxAge? Test that by checking
the cookie in the HTTP response.
2) Does cookiejar.Jar work properly? You can rely on that;
but if you think its tests are lacking: Feel free to provide a CL for
the test suite of Jar.

V.

-- 
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/ffcf1004-4bcd-44e6-aa08-982e3ecbcaacn%40googlegroups.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.


Re: [go-nuts] Temporary prevent preemption?

2022-06-29 Thread Brian Candler
Vice-versa. Asynchronous preemption is when the goroutine is *not* waiting 
in a syscall, but is performing computations.  If it spends too much time 
working, it will be kicked off and another goroutine given a chance to run 
on the same thread.

On Wednesday, 29 June 2022 at 17:24:21 UTC+1 TH wrote:

> Hey Kurtis,
>
> Is asynchronous preemption only the ones that are waiting for netpolls? So 
> when a call is waiting on a network receive or send, scheduler will context 
> switch? And when... lets say...  for { i++ } -loop get's preemptied, this 
> would be called synchronous preemption? Or is it vice versa?? Bit confused.
>
> Thanks
>
> On Wednesday, 29 June 2022 at 05:21:27 UTC+3 Kurtis Rader wrote:
>
>> The "asyncpreemptoff" debug option may be useful. See 
>> https://pkg.go.dev/runtime. Specifically, try running your program after 
>> doing "export GODEBUG=asyncpreemptoff=1". I'll leave it to others to 
>> explain why this can be risky; especially in a context like you described.
>>
>> On Tue, Jun 28, 2022 at 6:45 PM TH  wrote:
>>
>>> Hey,
>>>
>>> I'm writing some latency & speed sensitive routines that are processing 
>>> large amount of signal data in batches. When I run this in a standalone 
>>> program the speed is fine. However when I combine this to the rest of 
>>> software (>1000 goroutines, mainly network code) the speed gets reduced by 
>>> 2x.
>>>
>>> Are there any low-level ways to temporary prevent preemption of a 
>>> function or a goroutine?
>>>
>>> Alternatively I tried to run two piece of software in parallel, via 
>>> shm+IPC synchronization methods, but futex, posix mutex, pipes, all 
>>> produced latency jitter from 20us - 200us. If there's lower latency methods 
>>> or more stable ones, please do recommend.
>>>
>>> Thanks
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/60220814-5763-4be4-a811-a9a84f64f12dn%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> -- 
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>>
>

-- 
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/0b7d548e-c2e7-414a-898e-721ed110e8c7n%40googlegroups.com.


Re: [go-nuts] Temporary prevent preemption?

2022-06-29 Thread TH
Hey Kurtis,

Is asynchronous preemption only the ones that are waiting for netpolls? So 
when a call is waiting on a network receive or send, scheduler will context 
switch? And when... lets say...  for { i++ } -loop get's preemptied, this 
would be called synchronous preemption? Or is it vice versa?? Bit confused.

Thanks

On Wednesday, 29 June 2022 at 05:21:27 UTC+3 Kurtis Rader wrote:

> The "asyncpreemptoff" debug option may be useful. See 
> https://pkg.go.dev/runtime. Specifically, try running your program after 
> doing "export GODEBUG=asyncpreemptoff=1". I'll leave it to others to 
> explain why this can be risky; especially in a context like you described.
>
> On Tue, Jun 28, 2022 at 6:45 PM TH  wrote:
>
>> Hey,
>>
>> I'm writing some latency & speed sensitive routines that are processing 
>> large amount of signal data in batches. When I run this in a standalone 
>> program the speed is fine. However when I combine this to the rest of 
>> software (>1000 goroutines, mainly network code) the speed gets reduced by 
>> 2x.
>>
>> Are there any low-level ways to temporary prevent preemption of a 
>> function or a goroutine?
>>
>> Alternatively I tried to run two piece of software in parallel, via 
>> shm+IPC synchronization methods, but futex, posix mutex, pipes, all 
>> produced latency jitter from 20us - 200us. If there's lower latency methods 
>> or more stable ones, please do recommend.
>>
>> Thanks
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/60220814-5763-4be4-a811-a9a84f64f12dn%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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/19f9402b-4cd0-40ec-b613-a97744c0329fn%40googlegroups.com.


Re: [go-nuts] Is this a compilation optimization bug ?

2022-06-29 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2022-06-28 at 09:40 -0700, Ian Lance Taylor wrote:
> Please open an issue.  Thanks.

Filed https://go.dev/issue/53600.

Dan

-- 
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/979812a0eaa99be314465dca721fc2426a2f8009.camel%40kortschak.io.