gpt4 book ai didi

swift - 如何发送名称中包含 "_"的 HTTP header 字段?

转载 作者:行者123 更新时间:2023-11-30 10:44:04 25 4
gpt4 key购买 nike

我有一组随任务发送的 header 键。当我在服务器端查看并且所有包含 _ 的 header 都被跳过时,问题就出现了。如何在 header 值中插入 _ ?使用 Unicode 值?使用UTF-8?如果是的话,在哪里?

request.setValue("4435353", forHTTPHeaderField: "session_id")
request.setValue("08", forHTTPHeaderField: "channel-id")
request.setValue("5afde734-7655-406d-bda3-14ffa968d6ab", forHTTPHeaderField: "itau-client-id")
request.setValue("oO6oO3nW6iG8yV0kL6gU5yY1hE3qV6bH6yF0mK0tG4xX3qU2gD", forHTTPHeaderField: "itau-client-secret")
request.setValue("\(token_latam!)", forHTTPHeaderField: "token_latam")
request.setValue("itoken", forHTTPHeaderField: "application")
request.setValue("2017-12-12T12:30:00", forHTTPHeaderField: "timestamp")
request.setValue("c626ea51-edde-4172-8d16-1c2fd7700c13", forHTTPHeaderField: "itau-chave")
request.setValue("345353454", forHTTPHeaderField: "transaction_id")
request.setValue("\(encoded_operation!)", forHTTPHeaderField: "encoded_operation")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

服务器端:

{
"itau-chave": "c626ea51-edde-4172-8d16-1c2fd7700c13",
"accept": "*/*",
"timestamp": "2017-12-12T12:30:00",
"itau-client-secret": "oO6oO3nW6iG8yV0kL6gU5yY1hE3qV6bH6yF0mK0tG4xX3qU2gD",
"itau-client-id": "5afde734-7655-406d-bda3-14ffa968d6ab",
"channel-id": "08",
"application": "itoken",
"accept-language": "en-us",
"accept-encoding": "br, gzip, deflate",
"user-agent": "ItauPassEmpresa/1 CFNetwork/975.0.3 Darwin/18.5.0",
"content-type": "application/json"
}

最佳答案

只需尝试在前缀 header 名称中添加 : 即可了解更多信息,请阅读此 HTTP::Headers

关于swift - 如何发送名称中包含 "_"的 HTTP header 字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56178053/

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