Skip to content

Commit

Permalink
Merge branch 'release/0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Jan 23, 2019
2 parents 58f23ba + dbd44b4 commit 6f3667b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [0.8.2] - 2019-01-23
### Added
* Pass sender's Content-Type to receivers' one

## [0.8.1] - 2019-01-21
### Fixed
* Fix "main" and "types" in package.json to be imported as a library
Expand Down Expand Up @@ -99,7 +103,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
* Docker automated build on Docker Hub
* Support HTTPS

[Unreleased]: https://github.com/nwtgck/piping-server/compare/v0.8.1...HEAD
[Unreleased]: https://github.com/nwtgck/piping-server/compare/v0.8.2...HEAD
[0.8.2]: https://github.com/nwtgck/piping-seraver/compare/v0.8.1...v0.8.2
[0.8.1]: https://github.com/nwtgck/piping-seraver/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/nwtgck/piping-seraver/compare/v0.7.1...v0.8.0
[0.7.1]: https://github.com/nwtgck/piping-seraver/compare/v0.7.0...v0.7.1
Expand Down
42 changes: 32 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piping-server",
"version": "0.8.1",
"version": "0.8.2",
"description": "HTTP Piping Data Transfer Server",
"bin": {
"piping-server": "dist/src/index.js"
Expand Down Expand Up @@ -41,7 +41,7 @@
"power-assert": "^1.4.4",
"request": "^2.88.0",
"then-request": "^6.0.0",
"ts-node": "^7.0.1",
"ts-node": "^8.0.1",
"tslint": "^5.12.1",
"typescript": "^3.0.1"
},
Expand Down
5 changes: 5 additions & 0 deletions src/piping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ export class Server {
...(
sender.req.headers["content-length"] === undefined ?
{} : {"Content-Length": sender.req.headers["content-length"]}
),
// Add Content-Type if it exists
...(
sender.req.headers["content-type"] === undefined ?
{} : {"Content-Type": sender.req.headers["content-type"]}
)
});
}
Expand Down
19 changes: 19 additions & 0 deletions test/piping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ describe("piping.Server", () => {
assert.equal(data.headers["content-length"], "this is a content".length);
});

it("should pass sender's Content-Type to receivers' one", async () => {
// Get request promise
const reqPromise = thenRequest("GET", `${pipingUrl}/mydataid`);

// Send data
await thenRequest("POST", `${pipingUrl}/mydataid`, {
headers: {
"content-type": "text/plain"
},
body: "this is a content"
});

// Get data
const data = await reqPromise;

// Content-Type should be returned
assert.equal(data.headers["content-type"], "text/plain");
});

it("should handle connection (sender: O, receiver: O)", async () => {
// Send data
// (NOTE: Should NOT use `await` because of blocking a GET request)
Expand Down

0 comments on commit 6f3667b

Please sign in to comment.