Skip to content

Commit

Permalink
Merge pull request #168 from TerriaJS/fix-proxy-post
Browse files Browse the repository at this point in the history
Fix proxy POST
  • Loading branch information
tephenavies authored May 24, 2024
2 parents 3b66d7c + 5c3d523 commit b02b16c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push, pull_request]

# When a PR is updated, cancel the jobs from the previous version. Merges
# do not define head_ref, so use run_id to never cancel those jobs.
Expand All @@ -18,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 21.x]
node-version: [16.x, 18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Next version

### 4.0.1

* Fixed proxied upstream POST request being aborted when the stream associated with the downstream request is closed on Node v16+. This will now again correctly be triggered only when the socket is closed early.

### 4.0.0

* Removed conversion service (no longer used in TerriaJS 8+).
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ module.exports = function(options) {
// encoding : null means "body" passed to the callback will be raw bytes

var proxiedRequest;
req.on('close', function() {
if (proxiedRequest) {
res.once('close', function() {
if (proxiedRequest && !res.writableEnded) {
proxiedRequest.abort();
}
});
Expand Down
2 changes: 1 addition & 1 deletion spec/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('proxy', function() {
request(buildApp(openProxyOptions))
[methodName]('/_2h/example.com')
.set('Cache-Control', 'no-cache')
.set('x-give-response-status', '500')
.set('x-give-response-status', 500)
.expect(500)
.expect('cache-control', 'no-cache')
.end(assert(done));
Expand Down

0 comments on commit b02b16c

Please sign in to comment.