Skip to content

Commit b7e62be

Browse files
committed
Consider application/octet-stream as unknown media type
1 parent a444852 commit b7e62be

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/actor-dereference-http/lib/ActorDereferenceHttpBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export abstract class ActorDereferenceHttpBase extends ActorDereference implemen
112112
requestTime,
113113
status: httpResponse.status,
114114
headers: httpResponse.headers,
115-
mediaType: mediaType === 'text/plain' ? undefined : mediaType,
115+
mediaType: mediaType === 'text/plain' || mediaType === 'application/octet-stream' ? undefined : mediaType,
116116
version,
117117
cachePolicy: httpResponse.cachePolicy ?
118118
new DereferenceCachePolicyHttpWrapper(httpResponse.cachePolicy, maxAcceptHeaderLength) :

packages/actor-dereference-http/test/ActorDereferenceHttp-test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ describe('ActorDereferenceHttp', () => {
9898
if (action.input.includes('plaincontenttype')) {
9999
headers.set('content-type', 'text/plain');
100100
}
101+
if (action.input.includes('octetcontenttype')) {
102+
headers.set('content-type', 'application/octet-stream');
103+
}
101104
if (action.input.includes('missingcontenttype')) {
102105
headers.delete('content-type');
103106
}
@@ -180,6 +183,13 @@ describe('ActorDereferenceHttp', () => {
180183
expect(output.mediaType).toBeUndefined();
181184
});
182185

186+
it('should run with an application/octet-stream content type', async() => {
187+
const output = await actor.run({ url: 'https://www.google.com/octetcontenttype', context });
188+
expect(output.url).toBe('https://www.google.com/index.html');
189+
expect(output.headers).toEqual(new Headers({ 'content-type': 'application/octet-stream' }));
190+
expect(output.mediaType).toBeUndefined();
191+
});
192+
183193
it('should run with an empty content type and default to given content type', async() => {
184194
const headers = new Headers({
185195
'content-type': '',

0 commit comments

Comments
 (0)