Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: UsingHead always returns 0 for Content-Length header even when explicitly specified #126

Closed
pm7y opened this issue Apr 16, 2018 · 5 comments
Assignees

Comments

@pm7y
Copy link

pm7y commented Apr 16, 2018

The response to a HEAD request should be the length of the file (without the actual body) so something like this (below) should return 1024 in the Content-Length response header but it always returns 0. Something internally must be overwriting my value of "1024" back to "0".

server
    .Given(Request.Create().WithPath($"/SomeFile.zip").UsingHead())
    .RespondWith(Response.Create()
        .WithHeader("Content-Length", "1024")
    );
@StefH StefH self-assigned this Apr 16, 2018
@StefH
Copy link
Collaborator

StefH commented Apr 16, 2018

This is a restricted header:

https://msdn.microsoft.com/en-us/library/78h415ay(v=vs.110).aspx

StefH added a commit that referenced this issue Apr 17, 2018
@StefH
Copy link
Collaborator

StefH commented Apr 19, 2018

@pmcilreavy Does this answer your question?

@StefH StefH changed the title UsingHead always returns 0 for Content-Length header even when explicitly specified Question: UsingHead always returns 0 for Content-Length header even when explicitly specified Apr 24, 2018
@StefH
Copy link
Collaborator

StefH commented Apr 24, 2018

Closing

@StefH StefH closed this as completed Apr 24, 2018
@o7g8
Copy link

o7g8 commented May 16, 2018

@StefH the documentation https://msdn.microsoft.com/en-us/library/78h415ay(v=vs.110).aspx says

Tests whether the specified HTTP header can be set for the request.

But in this example the code attempts to set in the response.
Why shouldn't it be possible for a mock to specify an arbitrary value of Content-Length?

@StefH
Copy link
Collaborator

StefH commented May 25, 2018

Solved, see NuGet 1.0.3.18

@StefH StefH closed this as completed May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants