Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go FastHttp服务器";删除“;认证头_Go_Authorization_Httprequest_Fasthttp - Fatal编程技术网

Go FastHttp服务器";删除“;认证头

Go FastHttp服务器";删除“;认证头,go,authorization,httprequest,fasthttp,Go,Authorization,Httprequest,Fasthttp,编辑:已修复。要想知道出了什么问题,请看一看 当我尝试使用授权标头向FastHttp服务器发送请求时,标头将被删除。当我向邮递员发送请求时,不会删除授权标头 为了查看实际发送的报头,我设置了一个Undertow web服务器(Java),并将请求发送到该服务器 Java Web服务器的代码: Undertow-Undertow=Undertow.builder().addHttpListener(55446,“localhost”,新的HttpHandler()){ public void ha

编辑:已修复。要想知道出了什么问题,请看一看

当我尝试使用授权标头向FastHttp服务器发送请求时,标头将被删除。当我向邮递员发送请求时,不会删除授权标头

为了查看实际发送的报头,我设置了一个Undertow web服务器(Java),并将请求发送到该服务器

Java Web服务器的代码:

Undertow-Undertow=Undertow.builder().addHttpListener(55446,“localhost”,新的HttpHandler()){
public void handleRequest(最终HttpServerExchange HttpServerExchange)引发异常{
System.out.println(“------------------------------------------------”);
System.out.println(“Con from”+httpServerExchange.getHostName());
System.out.println(“Query”+httpServerExchange.getQueryString());
System.out.println(“Header”+httpServerExchange.getRequestHeaders().getHeaderNames().stream().map(str->str.toString()+”:“+httpServerExchange.getRequestHeaders().get(str.element()).collect(collector.joining(;”));
httpServerExchange.getRequestReceiver().receiveFullString((httpServerExchange1,s)->System.out.println(“Body”+s));
httpServerExchange.setStatusCode(400);
}
}).build();
下拖。开始();
使用邮递员发送请求时的输出:

------------------------------------------
Con from localhost
Query 
Header Accept: */*; Postman-Token: 275ba9bb-77cc-4c9f-baa5-653f60162551; Connection: keep-alive; Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx; Cache-Control: no-cache; Accept-Encoding: gzip, deflate; User-Agent: PostmanRuntime/7.21.0; Host: localhost:55446
Body 
当我随应用程序发送请求时的输出:

------------------------------------------
Con from localhost
Query 
Header test: f; Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml; Authorization: Bearer testtoken; Accept-Encoding: gzip, deflate; User-Agent: VSpedSync/DevBuild; Host: localhost:55446
Body 
在这两种情况下,都会发送授权标头,但当我将请求发送到FastHttp服务器时,只有来自Postman的请求包含标头


我很困惑,到底为什么会发生这种情况?

请分享您的FastHttp服务器源代码的相关部分,这样我们就可以看到您是如何检索头的(这里有一个最简单的可行示例;您展示的是可以工作的java代码,而不是不能工作的golang代码)@Brits服务器源代码可在此处找到:Im使用/auth/check端点。