Added getResponseDate helper and add etag for all responses
MODIFY
lib/src/common.dart
lib/src/common.dart
@@ -9,6 +9,7 @@ import "dart:convert"
import "package:html/dom.dart" as html;
import "package:html/parser.dart" as html_parser;
import "package:http/http.dart" as http;
+import 'package:http_parser/http_parser.dart' as http_parser;
import "package:quiver/async.dart" show FutureGroup;
import "package:json_annotation/json_annotation.dart";
import "package:xml/xml.dart" as xml;
@@ -63,3 +64,14 @@ part "common/util/oauth2.dart";
part "common/util/pagination.dart";
part "common/util/service.dart";
part "common/util/utils.dart";
+
+void _applyExpandos(Object target, http.Response response) {
+ _etagExpando[target] = response.headers['etag'];
+ _dateExpando[target] = http_parser.parseHttpDate(response.headers['date']);
+}
+
+final _etagExpando = new Expando<String>('etag');
+final _dateExpando = new Expando<DateTime>('date');
+
+String getResponseEtag(Object obj) => _etagExpando[obj];
+DateTime getResponseDate(Object obj) => _dateExpando[obj];

MODIFY
lib/src/common/github.dart
lib/src/common/github.dart
@@ -237,10 +237,13 @@ class GitHub {
var json = jsonDecode(response.body);
if (convert == null) {
+ _applyExpandos(json, response);
return json;
}
- return convert(json);
+ final returnValue = convert(json);
+ _applyExpandos(returnValue, response);
+ return returnValue;
}
/// Handles Post Requests that respond with JSO

MODIFY
pubspec.yaml
pubspec.yaml
@@ -8,6 +8,7 @@ environment:
dependencies:
html: '>=0.12.0 <0.14.0'
http: '^0.11.3'
+ http_parser: ^3.1.1
json_annotation: '^0.2.8'
quiver: '>=0.20.0 <0.29.0'
xml: '>=2.0.0 <4.0.0'

Added getResponseDate helper and add etag for all responses