MCPcopy Create free account
hub / github.com/parse-community/parse-server / constructor

Method constructor

src/request.js:7–56  ·  view source on GitHub ↗
(response, body)

Source from the content-addressed store, hash-verified

5
6class HTTPResponse {
7 constructor(response, body) {
8 let _text, _data;
9 this.status = response.statusCode;
10 this.headers = response.headers || {};
11 this.cookies = this.headers['set-cookie'];
12
13 if (typeof body == 'string') {
14 _text = body;
15 } else if (Buffer.isBuffer(body)) {
16 this.buffer = body;
17 } else if (typeof body == 'object') {
18 _data = body;
19 }
20
21 const getText = () => {
22 if (!_text && this.buffer) {
23 _text = this.buffer.toString('utf-8');
24 } else if (!_text && _data) {
25 _text = JSON.stringify(_data);
26 }
27 return _text;
28 };
29
30 const getData = () => {
31 if (!_data) {
32 try {
33 _data = JSON.parse(getText());
34 } catch {
35 /* */
36 }
37 }
38 return _data;
39 };
40
41 Object.defineProperty(this, 'body', {
42 get: () => {
43 return body;
44 },
45 });
46
47 Object.defineProperty(this, 'text', {
48 enumerable: true,
49 get: getText,
50 });
51
52 Object.defineProperty(this, 'data', {
53 enumerable: true,
54 get: getData,
55 });
56 }
57}
58
59const clients = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected