简体   繁体   中英

Request header in rest webservice as Object

我想在Rest Web服务上发送请求标头,而不是作为字符串发送,而是作为自定义对象发送,无论如何要这样做?

No, an HTTP header must be a string. See https://developer.mozilla.org/es/docs/Web/HTTP/Headers

HTTP headers allow the client and the server to pass additional information with the request or the response. A request header consists of its case-insensitive name followed by a colon ':', then by its value (without line breaks). Leading white space before the value is ignored.

But you can encode a custom object in a header, for example using JSON + base64

 CustomHeader: eyJhIjoiYiJ9     // {"a":"b"} in base64

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM