Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1319)

Unified Diff: pkg/oauth2/lib/src/handle_access_token_response.dart

Issue 216603010: Rip out dart:io from pkg/http wherever possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/oauth2/CHANGELOG.md ('k') | pkg/oauth2/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/oauth2/lib/src/handle_access_token_response.dart
diff --git a/pkg/oauth2/lib/src/handle_access_token_response.dart b/pkg/oauth2/lib/src/handle_access_token_response.dart
index 11a6fb9fe1756a4d9e6d40afb472984574b933c8..576636265cf1846c2cafd8351e225fe5dc393b0a 100644
--- a/pkg/oauth2/lib/src/handle_access_token_response.dart
+++ b/pkg/oauth2/lib/src/handle_access_token_response.dart
@@ -4,10 +4,10 @@
library handle_access_token_response;
-import 'dart:io';
import 'dart:convert';
import 'package:http/http.dart' as http;
+import 'package:http_parser/http_parser.dart';
import 'credentials.dart';
import 'authorization_exception.dart';
@@ -31,15 +31,13 @@ Credentials handleAccessTokenResponse(
_validate(response, tokenEndpoint, condition, message);
var contentType = response.headers['content-type'];
- if (contentType != null) {
- contentType = ContentType.parse(contentType);
- }
+ if (contentType != null) contentType = new MediaType.parse(contentType);
// The spec requires a content-type of application/json, but some endpoints
// (e.g. Dropbox) serve it as text/javascript instead.
validate(contentType != null &&
- (contentType.value == "application/json" ||
- contentType.value == "text/javascript"),
+ (contentType.mimeType == "application/json" ||
+ contentType.mimeType == "text/javascript"),
'content-type was "$contentType", expected "application/json"');
var parameters;
@@ -105,10 +103,8 @@ void _handleErrorResponse(http.Response response, Uri tokenEndpoint) {
}
var contentType = response.headers['content-type'];
- if (contentType != null) {
- contentType = ContentType.parse(contentType);
- }
- validate(contentType != null && contentType.value == "application/json",
+ if (contentType != null) contentType = new MediaType.parse(contentType);
+ validate(contentType != null && contentType.mimeType == "application/json",
'content-type was "$contentType", expected "application/json"');
var parameters;
« no previous file with comments | « pkg/oauth2/CHANGELOG.md ('k') | pkg/oauth2/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698