【HTTP 】 协议格式错误:but found invalid character 0x7b at index 0 of header

报错:

java.lang.IllegalArgumentException: a header name can only contain “token” characters, but found invalid character 0x7b at index 0 of header ‘{’.

在这里插入图片描述

分析

这是一个非常经典的 HTTP 协议格式错误。

原因分析: HTTP 协议(以及 PyCharm 的 .http 文件格式)强制要求在 请求头(Headers) 和 请求体(Body) 之间必须有一个空行。

你当前的代码中,Content-Type: application/json 紧接着就是 {。服务器解析器没有读到空行,所以它认为 { 也是一个 HTTP Header 的名字,但 { (ASCII 0x7b) 是非法字符,所以报错。

解决方法: 在 Content-Type 和 JSON 的第一个 { 之间加一个空行。

fix

在这里插入图片描述

Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915404, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'TerminateSelfAbility abilityName:%p terminateMission:%d token:%u' with [0, 0, 0], error=unsupported format character 'p' (0x70) at index 34 Param mismatch: 'trusport:TrusportResultReportToUi time m = %u, d = %u, h = %u, m = %u, s = %u' needs 5, got 4 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015914436, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015914664, 1], error=unsupported format character 'p' (0x70) at index 28 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915716, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'TerminateSelfAbility abilityName:%p terminateMission:%d token:%u' with [0, 0, 0], error=unsupported format character 'p' (0x70) at index 34 Format failed: 'during time error, alsStart=%lld alsEnd=%lld' with [0, 2688063], error=unsupported format character 'l' (0x6c) at index 30 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015914664, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915472, 1], error=unsupported format character 'p' (0x70) at index 28 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[ALARM]AlarmMaxNumToApp enter %{publica}d.' with [40], error=unsupported format character '{' (0x7b) at index 31 Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'TerminateSelfAbility abilityName:%p terminateMission:%d token:%u' with [0, 1, 1], error=unsupported format character 'p' (0x70) at index 34 Format failed: 'TerminateAbility want is %p' with [0], error=unsupported format character 'p' (0x70) at index 26 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'TerminateAbility want is %p' with [0], error=unsupported format character 'p' (0x70) at index 26 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'TerminateAbility want is %p' with [0], error=unsupported format character 'p' (0x70) at index 26 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915716, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'during time error, alsStart=%lld alsEnd=%lld' with [0, 3908607], error=unsupported format character 'l' (0x6c) at index 30 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'during time error, alsStart=%lld alsEnd=%lld' with [0, 4211481], error=unsupported format character 'l' (0x6c) at index 30 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015914664, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915248, 1], error=unsupported format character 'p' (0x70) at index 28 Format failed: 'terminate task packageName:%p, isAppScheduling_:%d' with [1015915404, 0], error=unsupported format character 'p' (0x70) at index 28 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.watch.health.arrhythmia', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'FM_GetSupportStatusProc packageName = [%s] status = %u' with ['com.huawei.health.sleepapnea', '<str@0x1??>'], error=%u format: a real number is required, not str Format failed: 'GetViewIDFromMapping fail, index = %{ public }d' with [4294967295], error=unsupported format character '{' (0x7b) at index 36 Format failed: '[MSG]MESSAGE_CommonInit: msgUniqueId=%lld.' with [0], error=unsupported format character 'l' (0x6c) at index 39 Format failed: '[ALARM]AlarmMaxNumToApp enter %{publica}d.' with [40], error=unsupported format character '{' (0x7b) at index 31
最新发布
12-06
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

等风来不如迎风去

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值