Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Copy headers from content before compressing
Browse files Browse the repository at this point in the history
  • Loading branch information
azzlack committed Sep 16, 2014
1 parent 8164779 commit 757cb6a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,44 @@ protected async override Task SerializeToStreamAsync(Stream stream, TransportCon
/// </summary>
private void CopyHeaders()
{
// Allow: {methods}
foreach (var allow in this.originalContent.Headers.Allow)
{
this.Headers.Allow.Add(allow);
}

// Content-Disposition: {disposition-type}; {disposition-param}
this.Headers.ContentDisposition = this.originalContent.Headers.ContentDisposition;

// Content-Encoding: {content-encodings}
this.Headers.ContentEncoding.Add(compressor.EncodingType);

// Content-Language: {languages}
foreach (var language in this.originalContent.Headers.ContentLanguage)
{
this.Headers.ContentLanguage.Add(language);
}

// Content-Type: {media-types}
this.Headers.ContentType = this.originalContent.Headers.ContentType;

// Content-Location: {uri}
this.Headers.ContentLocation = this.originalContent.Headers.ContentLocation;

// Content-MD5: {md5-digest}
this.Headers.ContentMD5 = this.originalContent.Headers.ContentMD5;

// Content-Range: {range}
this.Headers.ContentRange = this.originalContent.Headers.ContentRange;

// Content-Type: {media-types}
this.Headers.ContentType = this.originalContent.Headers.ContentType;

// Expires: {http-date}
this.Headers.Expires = this.originalContent.Headers.Expires;

// LastModified: {http-date}
this.Headers.LastModified = this.originalContent.Headers.LastModified;
}

/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions src/NuGetPackage/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Microsoft.AspNet.WebApi.MessageHandlers.Compression</id>
<version>1.2.0</version>
<version>1.2.1</version>
<title>Microsoft ASP.NET Web API Compression Support</title>
<authors>Ove Andersen</authors>
<owners>EyeCatch</owners>
Expand All @@ -18,8 +18,7 @@ Supported Platforms:
- Portable Class Libraries
</description>
<releaseNotes>
Fixed bug wuth content stream sometimes being disposed before returning.
Fixed bug with 504 error when returning ByteArrayContent.
Now properly copies headers from the content it is going to compress.
</releaseNotes>
<summary>
Module for ASP.NET Web API that enables GZip and Deflate support for incoming and outgoing requests. Please note that this is not an official Microsoft package.
Expand All @@ -33,7 +32,7 @@ Fixed bug with 504 error when returning ByteArrayContent.
<dependencies>
<group>
<dependency id="Microsoft.Net.Http" version="2.2.28" />
<dependency id="Microsoft.Bcl.Compression" version="3.9.83" />
<dependency id="Microsoft.Bcl.Compression" version="3.9.85" />
</group>
</dependencies>
<references></references>
Expand Down

0 comments on commit 757cb6a

Please sign in to comment.