guodongxiaren commented on a change in pull request #1529: URL: https://github.com/apache/incubator-brpc/pull/1529#discussion_r698961596
########## File path: docs/cn/http_client.md ########## @@ -114,7 +114,9 @@ URL的一般形式如下图: 若用户没有填且URL中包含host,比如http://www.foo.com/path,则http request中会包含"Host: www.foo.com"。 -若用户没有填且URL不包含host,比如"/index.html?name=value",则框架会以目标server的ip和port为Host,地址为10.46.188.39:8989的http server将会看到"Host: 10.46.188.39:8989"。 +若用户没有填且URL不包含host,比如"/index.html?name=value",但如果Channel初始化的地址包含域名,则框架会以域名作为Host,比如"http://www.foo.com",该http server将会看到"Host: www.foo.com"。如果地址是"http://www.foo.com:8989",则该http server将会看到"Host: www.foo.com"。 + Review comment: 有一点问题,如果调用的是 channel.Init("www.aa.com", 8899),那么对方收到的Host还是不包含端口号的。因为InitSingle中解析的原始地址,是Init的第一个参数。 感觉不存在十全十美的解决方案,我感觉还是要在CallMethod的时候,当uri不包含host的时候,把host和port都拼上。不影响uri中包含host时的处理逻辑。 另外一个方案就是在两个Init重载中,记录一下(新增bool成员变量存储标记,或者直接存原始port),InitSingle中判断是否单独设置了port参数。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
