Skip to content

Commit

Permalink
Fix problem with cache URL examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Oct 12, 2019
1 parent a6a7b44 commit 5fea4ca
Show file tree
Hide file tree
Showing 6 changed files with 474 additions and 13 deletions.
11 changes: 4 additions & 7 deletions locator/locate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import 'dart:io';

Future<void> main(List<String> args) async {
var client = new HttpClient();
var request = await client.postUrl(Uri.parse("https://lcdn-locator.apple.com/lcdn/locate"));
var request = await client
.postUrl(Uri.parse("https://lcdn-locator.apple.com/lcdn/locate"));
request.writeln(json.encode({
"ranked-results": true,
"locator-tag": "#f5cfd4d0",
"local-addresses": [
args[0]
],
"public-address-ranges": [
[]
],
"local-addresses": [args[0]],
"public-address-ranges": [[]],
"locator-software": [
{
"build": "19A578c",
Expand Down
2 changes: 1 addition & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ A few things to note, the path of the request seems to be the path of the asset
```text
Cache URL: http://10.0.0.60:54439/2019FallSeed/mobileassets/061-28461/73D248DA-E92B-11E9-87BD-36A73FE00C7B/com_apple_MobileAsset_SoftwareUpdateDocumentation/a080e3173e75180afa7ea1a15f469ed839f60260.zip?source=updates-http.cdn-apple.com
Source URL: http://updates-http.cdn-apple.com:443/2019FallSeed/mobileassets/061-28461/73D248DA-E92B-11E9-87BD-36A73FE00C7B/com_apple_MobileAsset_SoftwareUpdateDocumentation/a080e3173e75180afa7ea1a15f469ed839f60260.zip
Source URL: http://updates-http.cdn-apple.com/2019FallSeed/mobileassets/061-28461/73D248DA-E92B-11E9-87BD-36A73FE00C7B/com_apple_MobileAsset_SoftwareUpdateDocumentation/a080e3173e75180afa7ea1a15f469ed839f60260.zip
```

The cache server should then download the URL if it is not in the cache, and stream the results while downloading.
Expand Down
7 changes: 4 additions & 3 deletions server/build-cache-url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ void main(List<String> args) {
var cacheServerUrl = Uri.parse(args[0]);
var sourceDataUrl = Uri.parse(args[1]);

var url = cacheServerUrl.replace(path: sourceDataUrl.path, queryParameters: {
"source": sourceDataUrl.host
}..addAll(sourceDataUrl.queryParameters));
var url = cacheServerUrl.replace(
path: sourceDataUrl.path,
queryParameters: {"source": sourceDataUrl.host}
..addAll(sourceDataUrl.queryParameters));
print(url);
}
9 changes: 7 additions & 2 deletions server/build-source-url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ void main(List<String> args) {
var cacheServerUrl = Uri.parse(args[0]);

var sourceHost = cacheServerUrl.queryParameters["source"];
var newUrlParams = new Map<String, String>.from(cacheServerUrl.queryParameters);
var newUrlParams =
new Map<String, String>.from(cacheServerUrl.queryParameters);
newUrlParams.remove("source");

var url = cacheServerUrl.replace(scheme: "http", port: 443, host: sourceHost, queryParameters: newUrlParams);
var url = cacheServerUrl.replace(
scheme: "http",
port: 80,
host: sourceHost,
queryParameters: newUrlParams);
var urlString = url.toString();
if (urlString.endsWith("?")) {
urlString = urlString.substring(0, urlString.length - 1);
Expand Down
Loading

0 comments on commit 5fea4ca

Please sign in to comment.