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 19, 2023
1 parent 38fd05e commit e9ca7ed
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 @@ -540,12 +540,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 @@ -334,8 +334,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 e9ca7ed

Please sign in to comment.