gpt4 book ai didi

netflix-zuul - Netflix Zuul 查询字符串编码

转载 作者:行者123 更新时间:2023-12-04 19:45:10 26 4
gpt4 key购买 nike

通过 Zuul 向客户端发送请求时,Zuul 似乎更改了查询字符串。更具体地说,如果客户端应该收到一个 url 编码的查询字符串,Zuul 会对查询字符串进行一次解码。下面是一个具体的例子:

如果“http://localhost:8080/demo/demo?a=http%3A%2F%2Fsomething/ ”被发送到客户端,客户端会收到一个查询字符串“a= http://something/”。

查看 Zuul 的代码,函数“buildZuulRequestQueryParams”使用“HTTPRequestUtils.getInstance().getQueryParams();”解码查询字符串。

这是一个想要的功能还是一个错误?

最佳答案

Zuul 实际上提供了一个标志来禁用这种行为。

8.9 Query String Encoding When processing the incoming request, query params are decoded so that they can be available for possible modifications in Zuul filters. They are then re-encoded the backend request is rebuilt in the route filters. The result can be different than the original input if (for example) it was encoded with Javascript’s encodeURIComponent() method. While this causes no issues in most cases, some web servers can be picky with the encoding of complex query string.

To force the original encoding of the query string, it is possible to pass a special flag to ZuulProperties so that the query string is taken as is with the HttpServletRequest::getQueryString method, as shown in the following example:

application.yml.


 zuul:
forceOriginalQueryStringEncoding: true

[Note] This special flag works only with SimpleHostRoutingFilter. Also, you loose the ability to easily override query parameters with RequestContext.getCurrentContext().setRequestQueryParams(someOverriddenParameters), because the query string is now fetched directly on the original HttpServletRequest.



8. Router and Filter: Zuul

关于netflix-zuul - Netflix Zuul 查询字符串编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36475845/

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