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

Unified Diff: sdk/lib/_internal/pub/lib/src/hosted_source.dart

Issue 16351003: Move pub over to using the pub.dartlang.org API v2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 6 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 | « sdk/lib/_internal/pub/lib/src/command_uploader.dart ('k') | sdk/lib/_internal/pub/lib/src/http.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/hosted_source.dart
diff --git a/sdk/lib/_internal/pub/lib/src/hosted_source.dart b/sdk/lib/_internal/pub/lib/src/hosted_source.dart
index a5c99924d6ef5743978c97a69476ab543c351edb..beabfd1d3d6f773ab54aedaa43b78287013aa326 100644
--- a/sdk/lib/_internal/pub/lib/src/hosted_source.dart
+++ b/sdk/lib/_internal/pub/lib/src/hosted_source.dart
@@ -34,13 +34,13 @@ class HostedSource extends Source {
/// site.
Future<List<Version>> getVersions(String name, description) {
var url = _makeUrl(description,
- (server, package) => "$server/packages/$package.json");
+ (server, package) => "$server/api/packages/$package");
log.io("Get versions from $url.");
- return httpClient.read(url).then((body) {
+ return httpClient.read(url, headers: PUB_API_HEADERS).then((body) {
var doc = json.parse(body);
return doc['versions']
- .map((version) => new Version.parse(version))
+ .map((version) => new Version.parse(version['version']))
.toList();
}).catchError((ex) {
var parsed = _parseDescription(description);
@@ -53,15 +53,17 @@ class HostedSource extends Source {
Future<Pubspec> describeUncached(PackageId id) {
// Request it from the server.
var url = _makeVersionUrl(id, (server, package, version) =>
- "$server/packages/$package/versions/$version.yaml");
+ "$server/api/packages/$package/versions/$version");
log.io("Describe package at $url.");
- return httpClient.read(url).then((yaml) {
+ return httpClient.read(url, headers: PUB_API_HEADERS).then((version) {
+ version = json.parse(version);
+
// TODO(rnystrom): After this is pulled down, we could place it in
// a secondary cache of just pubspecs. This would let us have a
// persistent cache for pubspecs for packages that haven't actually
// been installed.
- return new Pubspec.parse(null, yaml, systemCache.sources);
+ return new Pubspec.fromMap(version['pubspec'], systemCache.sources);
}).catchError((ex) {
var parsed = _parseDescription(id.description);
_throwFriendlyError(ex, id, parsed.last);
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command_uploader.dart ('k') | sdk/lib/_internal/pub/lib/src/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698