你好有人能解释一下你是如何设置type
的吗?对于 request
和 response
的类型给出 html
元素 ?
示例:
如果我想发送 form
发送一些 files
和一个 POCO
并收到 stream
我会用 type=multipart/form-data
;会 type
在这种情况下,请参阅 request
还是预期的响应?
<form type="multipart/form-data"><input type="file"></form>
在本例中为 type
明确指的是请求。但这意味着 server
处理请求的必须设置 response.type
至 application/octet-stream
.
所以根据这个原因,我认为你在 form
中设置的内容是 request
类型。
但是然后我无法理解这个矛盾:
<a class="button" type="application/octet-stream" href="http://localhost:5300/get" download>Click here for dld</a>
在我没有设置 type
之前我无法下载文件response 在这里。我尝试在服务器中设置响应类型,但它没有用。所以在这种情况下,这里的 type 指的是 response
而不是 request
.
有人可以解释一下吗?是否有 html
的列表?上的元素
他们指的是什么 type
? (request
或预期的 response
的类型)?
PS
长话短说:为什么 form
引用request
通过 type
和 a
指的是response
. 当他想发送内容类型为 A
的请求时,怎么可能有原因呢?他的回复是类型 B
.
最佳答案
But then it means that the server that processes the request has to set the response.type to application/octet-stream.
没有。服务器可以响应任何类型的内容。
application/octet-stream
是一个毫无意义的“这是一个字节流”。通常,您会想要描述响应的实际内容类型的内容。
Can someone please shed some light?
type
<a>
上的属性元素指的是预期 响应类型。这允许机器人在期望得到它无法理解的响应时避免点击链接。
由于链接触发了GET请求,所以没有请求体来描述anyway的类型。
Is there a list with the html elements on what they refer by type ?
HTML 规范描述了它出现的每个元素的类型属性。例如script链接到 this type .
How can one reason when he wants to send a request whose content is type A and his response is type B
您几乎从不需要告诉客户期望的类型,所以不用。只有在构建带正文的 HTTP 请求时才需要担心它。
关于html - 了解 http 请求和响应中的内容类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54691534/