Skip to content

Commit 6b411ad

Browse files
authored
revert the preserve host header change as it failed on Antares (#114)
1 parent cee4cf7 commit 6b411ad

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/AspNetCore/Inc/protocolconfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class PROTOCOL_CONFIG
3333
return m_msTimeout;
3434
}
3535

36+
BOOL
37+
QueryPreserveHostHeader() const
38+
{
39+
return m_fPreserveHostHeader;
40+
}
41+
3642
BOOL
3743
QueryReverseRewriteHeaders() const
3844
{
@@ -84,6 +90,7 @@ class PROTOCOL_CONFIG
8490
private:
8591

8692
BOOL m_fKeepAlive;
93+
BOOL m_fPreserveHostHeader;
8794
BOOL m_fReverseRewriteHeaders;
8895
BOOL m_fIncludePortInXForwardedFor;
8996

src/AspNetCore/Src/forwardinghandler.cxx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,21 @@ FORWARDING_HANDLER::GetHeaders(
635635
// this is wrong but Kestrel has dependency on it.
636636
// should change it in the future
637637
//
638-
if (FAILED(hr = PATH::SplitUrl(pRequest->GetRawHttpRequest()->CookedUrl.pFullUrl,
639-
&fSecure,
640-
&struDestination,
641-
&struUrl)) ||
642-
FAILED(hr = strTemp.CopyW(struDestination.QueryStr())) ||
643-
FAILED(hr = pRequest->SetHeader(HttpHeaderHost,
644-
strTemp.QueryStr(),
645-
static_cast<USHORT>(strTemp.QueryCCH()),
646-
TRUE))) // fReplace
647-
{
648-
return hr;
638+
if (!pProtocol->QueryPreserveHostHeader())
639+
{
640+
if (FAILED(hr = PATH::SplitUrl(pRequest->GetRawHttpRequest()->CookedUrl.pFullUrl,
641+
&fSecure,
642+
&struDestination,
643+
&struUrl)) ||
644+
FAILED(hr = strTemp.CopyW(struDestination.QueryStr())) ||
645+
FAILED(hr = pRequest->SetHeader(HttpHeaderHost,
646+
strTemp.QueryStr(),
647+
static_cast<USHORT>(strTemp.QueryCCH()),
648+
TRUE))) // fReplace
649+
{
650+
return hr;
651+
}
649652
}
650-
651653
//
652654
// Strip all headers starting with MS-ASPNETCORE.
653655
// These headers are generated by the asp.net core module and

src/AspNetCore/Src/protocolconfig.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PROTOCOL_CONFIG::Initialize()
1111

1212
m_fKeepAlive = TRUE;
1313
m_msTimeout = 120000;
14+
m_fPreserveHostHeader = TRUE;
1415
m_fReverseRewriteHeaders = FALSE;
1516

1617
if (FAILED(hr = m_strXForwardedForName.CopyW(L"X-Forwarded-For")))

0 commit comments

Comments
 (0)