Live data from Hacker News

You know how HTTP GET requests are meant to be idempotent?

twitter.com

41–50 of 313 posts

Re: You know how HTTP GET requests are meant to be idempotent?

#41
post #38
post #29

Hello! Long-time lurker, and guilty dev behind the garage door. You can see the (broken) code I wrote here: https://github.com/wpearse/wemos-d1-garage-door-wifi I'll get around to fixing it later this week. Also, an apology: I should have used "side-effect-free" instead of "idempotent" in my tweets.

Fixed now: https://github.com/wpearse/wemos-d1-garage-door-wifi/commit/... I think. edit: updated link because left creds in the commit :-/

I hope that's not your real password!

Re: You know how HTTP GET requests are meant to be idempotent?

#42
post #15

When I recently added 'click to unsubscribe' functionality to my emails, the URL got wrote out into some logs. Those logs got written to a Slack channel and Slack loves to click any link it sees. Oh, and it doesn't respect robots.txt. But all I saw was every member of my list clicking 'unsubscribe'. It took a good hour to figure out exactly what was going on. Idempotence is not the problem here, by the way. That just…

Aren't you allowed to have your "click to unsubscribe" button lead to a page with a button that does a POST that actually unsubscribes? I feel like I've seen that approach in use.

Re: You know how HTTP GET requests are meant to be idempotent?

#43
post #41
post #38

Earlier quoted context omitted.

Fixed now: https://github.com/wpearse/wemos-d1-garage-door-wifi/commit/... I think. edit: updated link because left creds in the commit :-/

I hope that's not your real password!

EDIT: it's actually his address, I thought it was just a coincidence but you can the house on Street View... I removed the actual name as doxxing isn't great, sorry.

Re: You know how HTTP GET requests are meant to be idempotent?

#44
post #34
post #32

Earlier quoted context omitted.

“Toggle” is by definition not idempodent, because you get a different result each and every time. “Open” and “close” are idempodent, but not safe. The result of a GET request should always be idempodent and safe.

GET requests should have no side effects. In other words NOOP is idempotent

I'd just like to clarify that what you have described here is "safe" rather than "idempotent" [0]. Easy mistake to make, made the same mistake myself, idempotently (that is to say you only make it once ;)

Get, and NOOP, are both "safe" and naturally "idempotent" since the former encompasses the latter.

[0] https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Re: You know how HTTP GET requests are meant to be idempotent?

#45
post #29

Hello! Long-time lurker, and guilty dev behind the garage door. You can see the (broken) code I wrote here: https://github.com/wpearse/wemos-d1-garage-door-wifi I'll get around to fixing it later this week. Also, an apology: I should have used "side-effect-free" instead of "idempotent" in my tweets.

Anything side-effect-free is idempotent too, I suppose

No. A function which multiplies a number by two is side effect free, but is no idempotent.

Re: You know how HTTP GET requests are meant to be idempotent?

#46
post #41
post #38

Earlier quoted context omitted.

Fixed now: https://github.com/wpearse/wemos-d1-garage-door-wifi/commit/... I think. edit: updated link because left creds in the commit :-/

I hope that's not your real password!

Well according to Google it’s an address in Auckland NZ so I hope it’s not his address either.

Re: You know how HTTP GET requests are meant to be idempotent?

#47

Earlier quoted context omitted.

It would be sufficient to GET a resource that uses a script to POST the side-effect. Slack's user-agent probably isn't sophisticated enough to mess this up (although heaven help us when they implement their preview with something like headless chrome).

What would the problem be in just showing a button that says "Confirm unsubscribe" that sends a POST request? A lot of sites does something like that for their newsletter unsubscription.

I like the one-click URLs though. It irritates me to no end to click unsub, then wait for a page to load then repeat my intention.

Re: You know how HTTP GET requests are meant to be idempotent?

#48
post #34
post #32

Earlier quoted context omitted.

“Toggle” is by definition not idempodent, because you get a different result each and every time. “Open” and “close” are idempodent, but not safe. The result of a GET request should always be idempodent and safe.

GET requests should have no side effects. In other words NOOP is idempotent

IIRC, the rfc uses “safe” instead of “side effect free”, which is very similar, but not exactly the same.

Re: You know how HTTP GET requests are meant to be idempotent?

#49
post #33

Earlier quoted context omitted.

> REST is HTTP This is untrue. I hate to quote from Wikipedia, but it sums it up quite nicely: "REST is not a standard in itself, but RESTful implementations make use of standards, such as HTTP, URI, JSON, and XML" More colloquially: REST is what happens when people mix up transport layers in their head.

HTTP is an implementation of REST.

[deleted]

Re: You know how HTTP GET requests are meant to be idempotent?

#50
post #15

When I recently added 'click to unsubscribe' functionality to my emails, the URL got wrote out into some logs. Those logs got written to a Slack channel and Slack loves to click any link it sees. Oh, and it doesn't respect robots.txt. But all I saw was every member of my list clicking 'unsubscribe'. It took a good hour to figure out exactly what was going on. Idempotence is not the problem here, by the way. That just…

Facebook Messenger has the same problem, for a while my friends and I couldn't figure out why our referral links for a service weren't working, turns out Messenger was "using them up" for us.
Post reply on HN