What is idempotency in HTTP PUT? Can I disallow overwriting of a resource?
问题 I'm writing a REST API and I wish to allow authenticated users with the proper permissions to upload files via this API. I thought I'd use a PUT endpoint to handle this. I want to include a failsafe where the request will be rejected with a 400 -family error if the resource already exists and the user did not specify via a query that the resource should be overwritten (i.e. PUT https://my.server.com/api/files/path/to/file.txt?overwrite=1 ). The HTTP/1.1 RFC documentation of PUT suggests that