@uoa/lambda-tracing 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +6 -0
- package/dist/uoaHttps.js +6 -5
- package/package.json +1 -1
- package/uoaHttps.ts +6 -5
package/changelog.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
- Updated XML response parsing to include attribute tags
|
|
5
|
+
|
|
6
|
+
## 2.1.1
|
|
7
|
+
- Fixed issue where JSON requests & responses could only have content-type application/json. Will now parse request/response if content-type header includes "json" anywhere. If "json" is not present, it will check for "xml", then "image". If none are present, the raw string body will be used.
|
|
8
|
+
|
|
3
9
|
## 2.1.0
|
|
4
10
|
- Unexpected errors are now caught within the library. When this occurs, the request promise will reject with the error.
|
|
5
11
|
- http response promises will now be rejected if the response code is not in the 2xx range
|
package/dist/uoaHttps.js
CHANGED
|
@@ -111,17 +111,18 @@ function doHttpsRequest(options, resolve, reject) {
|
|
|
111
111
|
let parsedBody = body.toString();
|
|
112
112
|
//Get the response content-type header value so we can apply different parsing methods
|
|
113
113
|
const responseContentType = response.headers["content-type"]?.toLowerCase() ?? '';
|
|
114
|
-
if (responseContentType === '' || responseContentType.includes('
|
|
114
|
+
if (responseContentType === '' || responseContentType.includes('json')) {
|
|
115
115
|
parsedBody = JSON.parse(body.toString());
|
|
116
116
|
}
|
|
117
|
-
else if (responseContentType.includes('
|
|
117
|
+
else if (responseContentType.includes('xml')) {
|
|
118
118
|
const parser = new fast_xml_parser_1.XMLParser({
|
|
119
119
|
ignoreDeclaration: true,
|
|
120
|
-
ignorePiTags: true
|
|
120
|
+
ignorePiTags: true,
|
|
121
|
+
ignoreAttributes: false
|
|
121
122
|
});
|
|
122
123
|
parsedBody = parser.parse(body.toString());
|
|
123
124
|
}
|
|
124
|
-
else if (responseContentType.includes('image
|
|
125
|
+
else if (responseContentType.includes('image')) {
|
|
125
126
|
parsedBody = body.toString('base64');
|
|
126
127
|
}
|
|
127
128
|
if (response.statusCode !== undefined && response.statusCode >= 200 && response.statusCode < 300) {
|
|
@@ -144,7 +145,7 @@ function doHttpsRequest(options, resolve, reject) {
|
|
|
144
145
|
function setRequestBody(request, data) {
|
|
145
146
|
if (data) {
|
|
146
147
|
const requestContentType = request.getHeader('content-type')?.toString() ?? '';
|
|
147
|
-
if (requestContentType === '' || requestContentType.includes('
|
|
148
|
+
if (requestContentType === '' || requestContentType.includes('json')) {
|
|
148
149
|
//We serialize using JSON.stringify as a default, or if JSON is specified
|
|
149
150
|
request.write(JSON.stringify(data));
|
|
150
151
|
}
|
package/package.json
CHANGED
package/uoaHttps.ts
CHANGED
|
@@ -103,15 +103,16 @@ function doHttpsRequest(options: RequestOptions, resolve: any, reject: any): Cli
|
|
|
103
103
|
|
|
104
104
|
//Get the response content-type header value so we can apply different parsing methods
|
|
105
105
|
const responseContentType: string = response.headers["content-type"]?.toLowerCase() ?? '';
|
|
106
|
-
if (responseContentType === '' || responseContentType.includes('
|
|
106
|
+
if (responseContentType === '' || responseContentType.includes('json')) {
|
|
107
107
|
parsedBody = JSON.parse(body.toString());
|
|
108
|
-
} else if (responseContentType.includes('
|
|
108
|
+
} else if (responseContentType.includes('xml')) {
|
|
109
109
|
const parser = new XMLParser({
|
|
110
110
|
ignoreDeclaration: true,
|
|
111
|
-
ignorePiTags: true
|
|
111
|
+
ignorePiTags: true,
|
|
112
|
+
ignoreAttributes: false
|
|
112
113
|
});
|
|
113
114
|
parsedBody = parser.parse(body.toString());
|
|
114
|
-
} else if (responseContentType.includes('image
|
|
115
|
+
} else if (responseContentType.includes('image')) {
|
|
115
116
|
parsedBody = body.toString('base64');
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -135,7 +136,7 @@ function doHttpsRequest(options: RequestOptions, resolve: any, reject: any): Cli
|
|
|
135
136
|
function setRequestBody(request: ClientRequest, data: any) {
|
|
136
137
|
if (data) {
|
|
137
138
|
const requestContentType: string = request.getHeader('content-type')?.toString() ?? '';
|
|
138
|
-
if (requestContentType === '' || requestContentType.includes('
|
|
139
|
+
if (requestContentType === '' || requestContentType.includes('json')) {
|
|
139
140
|
//We serialize using JSON.stringify as a default, or if JSON is specified
|
|
140
141
|
request.write(JSON.stringify(data));
|
|
141
142
|
} else {
|