MCPcopy Index your code
hub / github.com/restify/node-restify / done

Function done

lib/plugins/bodyReader.js:104–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 }
103
104 function done() {
105 bodyWriter.end();
106
107 if (unsupportedContentEncoding) {
108 next(
109 new UnsupportedMediaTypeError(
110 {
111 info: {
112 contentEncoding: unsupportedContentEncoding
113 }
114 },
115 'content encoding not supported'
116 )
117 );
118 return;
119 }
120
121 if (maxBodySize && bytesReceived > maxBodySize) {
122 var msg = 'Request body size exceeds ' + maxBodySize;
123 var err;
124
125 // Between Node 0.12 and 4 http status code messages changed
126 // RequestEntityTooLarge was changed to PayloadTooLarge
127 // this check is to maintain backwards compatibility
128 if (PayloadTooLargeError !== undefined) {
129 err = new PayloadTooLargeError(msg);
130 } else {
131 err = new RequestEntityTooLargeError(msg);
132 }
133
134 next(err);
135 return;
136 }
137
138 if (!req.body.length) {
139 next();
140 return;
141 }
142
143 if (hash && md5 !== (digest = hash.digest('base64'))) {
144 next(new BadDigestError(MD5_MSG, md5, digest));
145 return;
146 }
147
148 next();
149 }
150
151 if (req.headers['content-encoding'] === undefined) {
152 // This handles the original else branch

Callers 15

nextFunction · 0.85
upgrade.test.jsFile · 0.85
context.test.jsFile · 0.85
query.test.jsFile · 0.85
plugins.test.jsFile · 0.85
multipart.test.jsFile · 0.85
simpleTestsFunction · 0.85

Calls 1

nextFunction · 0.50

Tested by 10

simpleTestsFunction · 0.68
testsWithOptionsFunction · 0.68
negativeTestsFunction · 0.68
nextFunction · 0.68
setupClientServerFunction · 0.68
sendFunction · 0.68
nextFunction · 0.68
finishFunction · 0.68
serveStaticTestFunction · 0.68
testNoAppendPathFunction · 0.68