Skip to content

Commit

Permalink
fixup! feat!: add proposal for new discovery API
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Sep 19, 2023
1 parent c0178ea commit f24d9e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions packages/binding-coap/src/coap-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ export default class CoapClient implements ProtocolClient {
req.setOption("Accept", "application/td+json");
return new Promise<Content>((resolve, reject) => {
req.on("response", (res: IncomingMessage) => {
let contentType = res.headers["Content-Format"];
if (typeof contentType !== "string") {
contentType = "application/td+json";
}
resolve({ type: contentType, body: Readable.from(res.payload) });
const contentType = (res.headers["Content-Format"] as string) ?? "application/td+json";
resolve(new Content(contentType, Readable.from(res.payload)));
});
req.on("error", (err: Error) => reject(err));
req.end();
Expand Down
2 changes: 1 addition & 1 deletion packages/binding-http/src/http-client-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,6 @@ export default class HttpClient implements ProtocolClient {
const response = await fetch(uri, { headers });
// TODO: Result should be validated
const body = ProtocolHelpers.toNodeStream(response.body as Readable);
return { type: response.headers.get("content-type"), body };
return new Content(response.headers.get("content-type") ?? "application/td+json", body);
}

Check warning on line 429 in packages/binding-http/src/http-client-impl.ts

View check run for this annotation

Codecov / codecov/patch

packages/binding-http/src/http-client-impl.ts#L421-L429

Added lines #L421 - L429 were not covered by tests
}

0 comments on commit f24d9e7

Please sign in to comment.