Skip to content

Commit fc48896

Browse files
committed
Use current protocol version in Via identifier
1 parent 801996c commit fc48896

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/OpenRasta.Plugins.ReverseProxy/ReverseProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async Task<ReverseProxyResponse> Send(ICommunicationContext context, stri
7777
string AppendViaHeaderToRequest(ICommunicationContext context, HttpRequestMessage requestMessage)
7878
{
7979
var viaIdentifier = _viaIdentifier ?? $"{context.Request.Uri.Host}:{context.Request.Uri.Port}";
80-
requestMessage.Headers.Add("via", $"1.1 {viaIdentifier}");
80+
requestMessage.Headers.Add("via", $"{context.PipelineData.Owin.RequestProtocol} {viaIdentifier}");
8181
return viaIdentifier;
8282
}
8383

src/OpenRasta.Plugins.ReverseProxy/ReverseProxyResponseCodec.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ namespace OpenRasta.Plugins.ReverseProxy
1212
public class ReverseProxyResponseCodec : IMediaTypeWriterAsync
1313
{
1414
readonly IResponse _response;
15+
string _protocol;
1516
public object Configuration { get; set; }
1617

1718

1819
public ReverseProxyResponseCodec(ICommunicationContext context)
1920
{
2021
_response = context.Response;
22+
_protocol = context.PipelineData.Owin.RequestProtocol;
2123
}
2224

2325
public async Task WriteTo(object entity, IHttpEntity response, IEnumerable<string> codecParameters)
@@ -28,7 +30,7 @@ public async Task WriteTo(object entity, IHttpEntity response, IEnumerable<strin
2830
_response.StatusCode = proxyResponse.StatusCode;
2931

3032
if (proxyResponse.Via != null)
31-
response.Headers.Add("via", proxyResponse.Via);
33+
response.Headers.Add("via", $"{_protocol} {proxyResponse.Via}");
3234

3335
if (proxyResponse.ResponseMessage != null)
3436
{

src/Tests/Plugins.ReverseProxy/via_headers/default_via_header.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public async Task request_domain_and_port_is_used()
1414
.FromServer("/proxy")
1515
.ToServer("/proxied", async ctx => ctx.Request.Headers["Via"])
1616
.GetAsync("http://source.example/proxy");
17-
response.Content.ShouldBe("1.1 source.example:80");
17+
response.Content.ShouldBe("HTTP/2.0 source.example:80");
1818

1919
var via = response.Message.Headers.Via.ShouldHaveSingleItem();
2020
via.ReceivedBy.ShouldBe("source.example:80");

src/Tests/Plugins.ReverseProxy/via_headers/pseudonym_via_header_request_absent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public async Task rp_is_added()
1414
.FromServer("/proxy", options=>options.Via.Pseudonym = "componentName")
1515
.ToServer("/proxied", async ctx => ctx.Request.Headers["Via"])
1616
.GetAsync("proxy");
17-
response.Content.ShouldBe("1.1 componentName");
17+
response.Content.ShouldBe("HTTP/2.0 componentName");
1818
}
1919
}
2020
}

src/Tests/Plugins.ReverseProxy/via_headers/pseudonym_via_header_request_present.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public async Task rp_is_appended()
1515
.ToServer("/proxied", async ctx => ctx.Request.Headers["Via"])
1616
.AddHeader("Via", "1.1 identifier")
1717
.GetAsync("proxy");
18-
response.Content.ShouldBe("1.1 identifier,1.1 componentName");
18+
response.Content.ShouldBe("1.1 identifier,HTTP/2.0 componentName");
1919
}
2020
}
2121
}

0 commit comments

Comments
 (0)