Skip to content

Commit

Permalink
fix(Server): fix body limit process
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Jul 22, 2022
1 parent 1c3a75f commit be38816
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/server/js/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Connection {
this._on_writable ? this._on_writable(offset) : true)
this.wsContext = wsContext
this._remote_address = null
this.processBodyData()
}

static create (app, request, response, wsContext = null) {
Expand Down
1 change: 1 addition & 0 deletions packages/server/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Routes {
const req = Request.create(conn)
const res = Response.create(conn)
try {
conn.processBodyData()
await callbacks(req, res, params)
} catch (e) {
this.log.error('Server Internal Error', e)
Expand Down
13 changes: 13 additions & 0 deletions test/cases/http-post-large.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const axios = require('axios')
const FormData = require('form-data')

module.exports = async function ({ HTTP_PORT }) {
const res = await axios({
method: 'post',
url: `http://localhost:${HTTP_PORT}/post`,
data: 'A'.repeat(2048000),
}).catch(e => e.response)
if (res.status !== 413) {
throw new Error(`Response ${res.status}`)
}
}
1 change: 1 addition & 0 deletions test/prepare/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = function (port) {
return new Promise((resolve, reject) => {
try {
app(new fastWS({
bodySize: '1mb',
logLevel: 'verbose',
cache: new LRUCache({
ttl: 1000 * 60 * 5,
Expand Down
1 change: 1 addition & 0 deletions test/prepare/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = function (port) {
fs.writeFileSync(cert_file_name, cert.cert)
try {
app(new fastWS({
bodySize: '1mb',
logLevel: 'verbose',
ssl: {
key_file_name,
Expand Down

0 comments on commit be38816

Please sign in to comment.