当前位置:网站首页>RestTemplate多个认证信息Authorization问题
RestTemplate多个认证信息Authorization问题
2022-06-21 18:14:00 【GodSure0914】
业务场景,自己通过程序拼接了一个请求头,然后将请求头放到HttpHeaders通过RestTemplate调用出口网关,接口测试时通过swagger调用是完全没有问题的,但是一发到服务器然后通过程序调用就会报错
通过日志可以看到,这里报的是json转换错误,但是通过log日志发现入参以及我自己拼接的Authorization均没有问题,最后在出口网关打印日志发现restTemplate在请求时传了两个Authorization过去,而网关只拿了第一个做解析,出现问题的原因是因为浏览器本身是有一个认证信息的,java代码在赋值这个认证信息的时候用了HttpHeaders 的add方法,而add方法是基于原本的信息增加的,所以网关解析的时候解析的只是浏览器的那一段,最终导致报错,将add改成set之后问题解决,最坑的是通过swagger本地调用根本发现不了这个问题!!!


边栏推荐
- Write down some pat topics (I)
- 【面试高频题】难度 1.5/5,常见的二分双指针面试题
- Medical expense list can be entered at a second speed, and OCR recognition can help double the efficiency
- Kubernetes 跨 StorageClass 迁移 Persistent Volumes 完全指南
- Qt Creator 7.0常见问题和常见用法
- 论文解读(USIB)《Towards Explanation for Unsupervised Graph-Level Representation Learning》
- Tableapi & SQL and example module of Flink
- R语言dist函数计算dataframe数据中两两样本之间的距离并返回样本间距离矩阵,将距离矩阵输入给hclust函数进行层次聚类分析,method参数指定两个组合数据点间的距离计算方式
- How to use devaxpress WPF to create the first MVVM application in winui?
- LeetCode个人题解(剑指offer 21-25)21. 调整数组顺序使奇数位于偶数前面,22. 链表中倒数第k个节点,24. 反转链表,25. 合并两个排序的链表
猜你喜欢

WMS仓库仓储管理系统源码

NPDP|如何做好产品生命周期管理?

在 KubeSphere 上部署 Apache Pulsar

Sword finger offer II 029 Sorted circular linked list

Use the uniapp framework to build the zheliban micro application (single sign on, embedded point, aging adaptation, RPC gateway)

系统集成项目管理工程师(软考中级)怎么备考?

2022年下半年传统产品经理国际资格认证招生简章(NPDP)

With a playback volume of up to 4000w+, how do couples get out of the ring by scattering dog food?
![2022年下半年深圳地区数据分析师认证(CPDA),[进入查看]](/img/9a/4fe513a71f5efc7cce318708d6931e.jpg)
2022年下半年深圳地区数据分析师认证(CPDA),[进入查看]
![[pwn基础]Pwntools学习](/img/72/0f80d2f91d772e361b6d23a67e2ca3.png)
[pwn基础]Pwntools学习
随机推荐
Medical expense list can be entered at a second speed, and OCR recognition can help double the efficiency
Sword finger offer II 029 Sorted circular linked list
Nacos configuration center source code
Security框架中使用FastJson反序列化SimpleGrantedAuthority
文件上传漏洞靶场分析 UPLOAD_LABS
[interval and topic prefix sum] line segment tree (dynamic open point) application problem
三叶的小伙伴们の经历分享 : 千秋澪(千秋总)
MFC interface library bcgcontrolbar v33.0 - Desktop alert window, grid control upgrade
nacos-配置中心-源码
剑指 Offer II 029. 排序的循环链表
Two ways of encrypting Excel files
动态规划【二】(线性dp)
Two problems that may occur in the use of ThreadLocal and thread pool
After the 80 version of Google browser, how to deal with the problem samesite cross domain problem
6月25日PMP考前指南,你需要做好这些
Yolov5 trains its own data set to report error records
298th weekly match
Experience sharing of Sanye's friends: Qianqiu Shu (general manager of Qianqiu)
【干货知识】Redis:从应用到底层,一文帮你搞定
SQL operation: with expression and its application