Live data from Hacker News

Curl is just the hobby

daniel.haxx.se

11–20 of 90 posts

Re: Curl is just the hobby

#11

> I would personally perhaps protest against the use of PUT for POSTing JSON, but nobody asked me. Just wondering, if the resource ID is known, I thought PUT is the recommended method? We usually use POST for creating a new resource for which you don't know an ID yet.

I also wondered, did some research and look at some examples and came to the opposite conclusion for my API.

Re: Curl is just the hobby

#12

> I would personally perhaps protest against the use of PUT for POSTing JSON, but nobody asked me. Just wondering, if the resource ID is known, I thought PUT is the recommended method? We usually use POST for creating a new resource for which you don't know an ID yet.

Auth requests are for a new session ID, not a new user ID.

It's a (C)reate in CRUD, not an (U)pdate.

POST - Create, GET - Retrieve, PUT - Update, DELETE - Delete

Re: Curl is just the hobby

#13

> I would personally perhaps protest against the use of PUT for POSTing JSON, but nobody asked me. Just wondering, if the resource ID is known, I thought PUT is the recommended method? We usually use POST for creating a new resource for which you don't know an ID yet.

According to RFC 9110:

- POST: Perform resource-specific processing on the request content.

- PUT: Replace all current representations of the target resource with the request content.

I interpret this as the only immediate side-effect of PUT is supposed to be replacing the target resource with the request content. Everything else is POST, but that does not mean that we can't use POST for everything. Thus, JSON via PUT is not inherently odd at all. Calling a random API using PUT with JSON arguments that executes some code other than replacing a resource, would be odd.

I do think, though, that PUT may very well implicitly create a resource, if the name of that resource is the argument to the put. That is just something that's rather odd, as, often, the server has authority over the names of new resources.

I find PUT particularly helpful, as, given these constraints, I assume that PUT is idempotent; POST is not.

Re: Curl is just the hobby

#14

Off topic but I find it wild that SF has API ads on bus shelters. Is that unusual/right in a dev hotspot, or have I been well underestimating just how intrinsic the tech culture is there? (I’m an Australian, so I guess my question applies to the US as much as SF)

I've travelled to SF (from Poland) and this has struck me too, together with lawyer ads.

Re: Curl is just the hobby

#15

> I would personally perhaps protest against the use of PUT for POSTing JSON, but nobody asked me. Just wondering, if the resource ID is known, I thought PUT is the recommended method? We usually use POST for creating a new resource for which you don't know an ID yet.

> Just wondering, if the resource ID is known, I thought PUT is the recommended method?

Recommended for what purpose?

The set of recommendations I'm familiar with is:

    GET:   requests without side effects
    POST:  requests with side effects
    PUT:   never use
    other: never use
POST gets special treatment from browsers for various security risks. Otherwise, methods don't differ. You can use PUT as part of an effort to feel like you and your server have a secret code, but it's fundamentally the same thing as doing `GET /path/to/resource/put`.

Re: Curl is just the hobby

#16
> https://daniel.haxx.se/blog/2024/04/22/curl-is-just-the-hobb... has a security policy called HTTP Strict Transport Security (HSTS), which means that Firefox can only connect to it securely. You can’t add an exception to visit this site.

That's aggravating. What's the workaround?

edit0: Chrome made more progress, then collided with Vodafone's shitty approximation to infrastructure which is known unsolvable.

edit1: Magic: https://web.archive.org/web/20240422091821/https://daniel.ha...

We are in trouble when some organisation manages to kill archive.org

Re: Curl is just the hobby

#17

> https://daniel.haxx.se/blog/2024/04/22/curl-is-just-the-hobb... has a security policy called HTTP Strict Transport Security (HSTS), which means that Firefox can only connect to it securely. You can’t add an exception to visit this site. That's aggravating. What's the workaround? edit0: Chrome made more progress, then collided with Vodafone's shitty approximation to infrastructure which is known unsolvable. edit1: M…

I thought this was fairly common?

Re: Curl is just the hobby

#18

> I would personally perhaps protest against the use of PUT for POSTing JSON, but nobody asked me. Just wondering, if the resource ID is known, I thought PUT is the recommended method? We usually use POST for creating a new resource for which you don't know an ID yet.

> Just wondering, if the resource ID is known, I thought PUT is the recommended method? Recommended for what purpose? The set of recommendations I'm familiar with is: GET: requests without side effects POST: requests with side effects PUT: never use other: never use POST gets special treatment from browsers for various security risks. Otherwise, methods don't differ. You can use PUT as part of an effort to feel like…

I don't think this is quite accurate, browsers won't treat PUT requests as safe the same way it does a get request.

Re: Curl is just the hobby

#19

> https://daniel.haxx.se/blog/2024/04/22/curl-is-just-the-hobb... has a security policy called HTTP Strict Transport Security (HSTS), which means that Firefox can only connect to it securely. You can’t add an exception to visit this site. That's aggravating. What's the workaround? edit0: Chrome made more progress, then collided with Vodafone's shitty approximation to infrastructure which is known unsolvable. edit1: M…

I thought this was fairly common?

It is and it's a best practice. I've never heard anyone complain about this.

Most security scanning software will ding any site that doesn't use HSTS

Post reply on HN