Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

No body for head request (#695) #699

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Titanium.Web.Proxy/Http/HttpWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ internal async Task ReceiveResponse(CancellationToken cancellationToken)
return;
}

Response.RequestMethod = Request.Method;

var httpStatus = await Connection.Stream.ReadResponseStatus(cancellationToken);
Response.HttpVersion = httpStatus.Version;
Response.StatusCode = httpStatus.StatusCode;
Expand Down
7 changes: 7 additions & 0 deletions src/Titanium.Web.Proxy/Http/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ public Response(byte[] body)
/// </summary>
public string StatusDescription { get; set; } = string.Empty;

internal string RequestMethod { get; set; }

/// <summary>
/// Has response body?
/// </summary>
public override bool HasBody
{
get
{
if (RequestMethod == "HEAD")
{
return false;
}

long contentLength = ContentLength;

// If content length is set to 0 the response has no body
Expand Down