FarmerMao

公司老的项目使用是php,要进行重构。其他团队使用php curl函数使用post方式调用Spring Cloud gateway 报time out错误。

但是使用postman测试是没有任何问题,php curl如果绕过网关直接访问接口也没有问题。结果发现了是因为:

使用Curl POST数据时,如果POST的数据大于1024字节,Curl并不会直接发起POST请求,而是分两步:

1、发送一个请求,Header中包含一个Expect:100-continue,询问Server是否愿意接受数据
2、接受到Server返回的100-continue回应后,才把数据Post到Server

这个也是Spring Cloud gateway一个Bug:https://github.com/spring-cloud/spring-cloud-gateway/issues/273

解决办法:配置路由转发的时候,去掉expect request Header

.route("openapi_route", p -> p.path(ORDER_CENTER_API + "/openapi/**").filters(f->f.removeRequestHeader("Expect"))
.uri("lb://order-xxxxx-service"))

分类:

技术点:

相关文章:

  • 2021-11-20
  • 2021-04-10
  • 2021-09-06
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2021-11-20
  • 2021-09-12
  • 2021-11-20
  • 2021-11-20
  • 2021-12-15
相关资源
相似解决方案