-
Notifications
You must be signed in to change notification settings - Fork 123
HttpRequestExtensions.GetUri throws Invalid URI when multiple Host headers are present #862
Comments
@Dmitry-Matveev You are already working on get URI right? Can you take a look at this ? |
@saikatguha, yep, I concur, the previous and the existing implementations are both subject to this issue. We now take AI is not supposed to fail the app under any circumstance, though - did it fail your request and service? |
@Dmitry-Matveev yes, all requests with multiple host headers fail before returning response to the client. If I remove AI logger, requests succeed. |
This is a bug - SDK should have try..catch..ed everything so as to never let user request fails. @Dmitry-Matveev please do the fix for this particular issue, while you are in that area, i will check entire SDK to make sure we have try..catched everything to conform to SDK guidance of never throwing. @saikatguha Thanks for bringing this to our attention. We'll address this before next stable release. |
@saikatguha , what would you say the expected behavior looks like apart from not failing? @cijothomas is ensuring we catch all exceptions in #865. Which value would you expect we report in Request URL if there are several hosts? The first host reported in URL or the last? |
Short version: Long version: Silently picking just one host (first or last) runs the risk that different components of the HTTP stack might pick inconsistently. For example, some authorization check component might pick the last value, while the logging component might pick the first value. This could result in nasty bugs impossible to diagnose. Note that the HTTP RFC itself suggests ignoring or errorring on multiple host fields. As per RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
The default behavior for generic singleton header fields that occur multiple times is to ignore. As per RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
|
should be fixed with #944. |
If you are reporting bug/issue, please provide detailed Repro instructions.
Repro Steps
Reason is that
request.Host.ToString()
returns comma-separated list of all the Host header values. If only one Host header is present, all is fine. However, if multiple Host headers are present, it results in a malformed URI being created in line 38 of the formhttps://host1,host2/path
Actual Behavior
Expected Behavior
Request completes as normal.
Version Info
SDK Version : 2.6.1
.NET Version : core
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) : Azure WebApps
The text was updated successfully, but these errors were encountered: