开发者

Error response in Django

开发者 https://www.devze.com 2023-03-24 07:58 出处:网络
A client wants to upload a file with the curl command, and I need to validate its data. What kind of response should I give to indicate that the file is corrupted, so that the client can use the exit

A client wants to upload a file with the curl command, and I need to validate its data.

What kind of response should I give to indicate that the file is corrupted, so that the client can use the exit 开发者_C百科code of curl to figure out whether or not it succeeded?

(i.e. I don't want to make him parse HTML.)


HTTP code 400 is Bad Request, which is probably the best bet here.

No reason for HTML, though. The response can be simply plain text, or something like JSON.

0

精彩评论

暂无评论...
验证码 换一张
取 消