gpt4 book ai didi

html - 了解 http 请求和响应中的内容类型

转载 作者:可可西里 更新时间:2023-11-01 17:17:28 26 4
gpt4 key购买 nike

你好有人能解释一下你是如何设置type的吗?对于 requestresponse 的类型给出 html元素 ?

示例:

如果我想发送 form发送一些 files和一个 POCO并收到 stream我会用 type=multipart/form-data ;会 type在这种情况下,请参阅 request还是预期的响应?

<form type="multipart/form-data"><input type="file"></form>

在本例中为 type明确指的是请求。但这意味着 server处理请求的必须设置 response.typeapplication/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通过 typea指的是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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com