Skip to content

Commit

Permalink
change content-type-parser to whatwg-mimetype (#1177)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyhtran committed Jan 5, 2022
2 parents fd3bdb5 + 2402232 commit 6fa0e6e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
40 changes: 28 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"dependencies": {
"axios": "^0.21.1",
"axios-ntlm": "^1.2.0",
"content-type-parser": "^1.0.2",
"debug": "^4.3.2",
"formidable": "^1.2.2",
"get-stream": "^6.0.1",
"lodash": "^4.17.21",
"sax": ">=0.6",
"strip-bom": "^3.0.0",
"uuid": "^8.3.2",
"whatwg-mimetype": "3.0.0",
"xml-crypto": "^2.1.3"
},
"repository": {
Expand Down Expand Up @@ -53,6 +53,7 @@
"@types/request": "^2.48.7",
"@types/sax": "^1.2.3",
"@types/uuid": "^8.3.1",
"@types/whatwg-mimetype": "^2.1.1",
"body-parser": "^1.15.2",
"colors": "^1.3.3",
"coveralls": "^3.1.1",
Expand Down
9 changes: 4 additions & 5 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

import * as req from 'axios';
import { NtlmClient } from 'axios-ntlm';
import * as contentTypeParser from 'content-type-parser';
import * as debugBuilder from 'debug';
import { ReadStream } from 'fs';
import * as url from 'url';

import { v4 as uuidv4 } from 'uuid';
import MIMEType = require('whatwg-mimetype');
import { gzipSync } from 'zlib';
import { IExOptions, IHeaders, IHttpClient, IMTOMAttachments, IOptions } from './types';
import { parseMTOMResp } from './utils';
Expand Down Expand Up @@ -212,9 +211,9 @@ export class HttpClient implements IHttpClient {
const isMultipartResp = res.headers['content-type'] && res.headers['content-type'].toLowerCase().indexOf('multipart/related') > -1;
if (isMultipartResp) {
let boundary;
const parsedContentType = contentTypeParser(res.headers['content-type']);
if (parsedContentType && parsedContentType.parameterList) {
boundary = ((parsedContentType.parameterList as any[]).find((item) => item.key === 'boundary') || {}).value;
const parsedContentType = MIMEType.parse(res.headers['content-type']);
if (parsedContentType) {
boundary = parsedContentType.parameters.get('boundary');
}
if (!boundary) {
return callback(new Error('Missing boundary from content-type'));
Expand Down

0 comments on commit 6fa0e6e

Please sign in to comment.