Skip to content

Commit

Permalink
fixup! feat: implement requestThingDescription method
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Dec 10, 2023
1 parent bc54366 commit 024ab4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/src/binding_coap/coap_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,10 @@ final class CoapClient implements ProtocolClient {
}

@override
Future<Content> requestThingDescription(Uri url) async =>
// TODO(JKRhb): Implement a different method here.
_sendDiscoveryRequest(
Future<Content> requestThingDescription(Uri url) async => _sendRequest(
url,
coap.RequestMethod.get,
form: null,
format: coap.CoapMediaType.applicationTdJson,
accept: coap.CoapMediaType.applicationTdJson,
);
}
14 changes: 11 additions & 3 deletions lib/src/binding_http/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,16 @@ final class HttpClient implements ProtocolClient {
}

@override
Future<Content> requestThingDescription(Uri url) {
// TODO: implement requestThingDescription
throw UnimplementedError();
Future<Content> requestThingDescription(Uri url) async {
final request = Request(HttpRequestMethod.get.methodName, url);
const tdContentType = 'application/td+json';
request.headers['Accept'] = tdContentType;

final response = await _client.send(request);

return Content(
response.headers['Content-Type'] ?? tdContentType,
response.stream,
);
}
}

0 comments on commit 024ab4a

Please sign in to comment.