Post to data: url — Are there any use cases?

2019-07-11 13:32发布

In the current HTML5 specification, one can POST a form to an action with the data scheme:

http://www.w3.org/TR/2011/WD-html5-20110525/association-of-controls-and-forms.html#form-submission-algorithm

It basically embeds the form data into a placeholder of the action attribute and navigates to the resulting data: url.

In the form submission algorithm described by the specification linked above, it is step 17.

I understand how the algorithm works. I wonder, though, whether there are any use cases for this facility in web applications. Are there any meaningful resources one can create this way (and for which there is no easier way to accomplish them)?

标签: forms html5 url
2条回答
太酷不给撩
2楼-- · 2019-07-11 14:12

I've seen this used in HTML5 drawing applications. Harmony by Mr. Doob is a great example: http://mrdoob.com/projects/harmony/

You hit save, and you're taken to a data:url that is your image rendered as a png from that url.

查看更多
我命由我不由天
3楼-- · 2019-07-11 14:22

This feature enables debugging how a browser treats a form without using a server. I think it would be particularly interesting if I were having difficulty with the encoding of a given form. Replacing an actual application URL with a data URI would allow you to see the form content that would be transmitted via POST.

That said, I wonder if this feature is implemented anywhere.

As for use in applications, there are more flexible ways to generate a data URL. It could be convenient if one had a page that was going to extract the substituted form data, parse it, and do something with it, but the extra level of indirection in the data URI seems unnecessary.

查看更多
登录 后发表回答