Update bugs.md

This commit is contained in:
xiehan
2024-01-10 14:12:38 +08:00
committed by GitHub
parent 0f6cc755a2
commit b717c61f56

View File

@@ -20,14 +20,15 @@ void f()
auto *task = WFTaskFactory::create_http_task("https://sogou/index.html", 0, 0, nullptr);
}
~~~
这时候http request里的Host必然填写的是"sogou"。此时如果sogou是一个upstream名指向域名www.sogou.com。并且我们开启了TLS SNI那么SNI server name信息就是wwww.sogou.com与http header里的Host是不一致的会导致SSL错误。
这时候http request里的Host必然填写的是"sogou"。此时如果sogou是一个upstream名指向域名www.sogou.com。并且我们开启了TLS SNI那么SNI server name信息就是www.sogou.com与http header里的Host是不一致的会导致SSL错误。
要解决这个问题用户可以在通过设置prepare函数在发送请求前修改Host让它与最终URL里的一致
~~~cpp
void f();
{
auto *task = WFTaskFactory::create_http_task("https://sogou/index.html", 0, 0, nullptr);
static_cast<WFClientTask<protocol::HttpRequest, protocol::HttpResponse> *>(task)->set_prepare([](WFHttpTask *task){
task->get_req()->set_header_pair("Host", task->get_current_uri()->host); // 这里得到实际uri里的host。
auto *t = static_cast<WFComplexClientTask<protocol::HttpRequest, protocol::HttpResponse> *>(task);
task->get_req()->set_header_pair("Host", t->get_current_uri()->host); // 这里得到实际uri里的host。
});
}
~~~