mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Workaround for HttpClient's caching
See http://stackoverflow.com/questions/6334788/windows-phone-7-webrequest-caching
This commit is contained in:
parent
83b816b3a2
commit
bf87dd9dba
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using IF.Lastfm.Core.Api.Enums;
|
using IF.Lastfm.Core.Api.Enums;
|
||||||
using IF.Lastfm.Core.Api.Helpers;
|
using IF.Lastfm.Core.Api.Helpers;
|
||||||
@ -34,6 +32,8 @@ public override Uri BuildRequestUrl()
|
|||||||
{"autocorrect", Convert.ToInt32(Autocorrect).ToString()}
|
{"autocorrect", Convert.ToInt32(Autocorrect).ToString()}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
base.DisableCaching(parameters);
|
||||||
|
|
||||||
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(apiUrl, UriKind.Absolute);
|
return new Uri(apiUrl, UriKind.Absolute);
|
||||||
}
|
}
|
@ -33,6 +33,8 @@ public override Uri BuildRequestUrl()
|
|||||||
{"autocorrect", Convert.ToInt32(Autocorrect).ToString()}
|
{"autocorrect", Convert.ToInt32(Autocorrect).ToString()}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
base.DisableCaching(parameters);
|
||||||
|
|
||||||
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(apiUrl, UriKind.Absolute);
|
return new Uri(apiUrl, UriKind.Absolute);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IF.Lastfm.Core.Api.Commands
|
namespace IF.Lastfm.Core.Api.Commands
|
||||||
@ -37,5 +38,15 @@ protected void AddPagingParameters(Dictionary<string, string> parameters)
|
|||||||
parameters.Add("page", Page.ToString());
|
parameters.Add("page", Page.ToString());
|
||||||
parameters.Add("limit", Count.ToString());
|
parameters.Add("limit", Count.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Annoying workaround for Windows Phone's caching...
|
||||||
|
/// see http://stackoverflow.com/questions/6334788/windows-phone-7-webrequest-caching
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parameters"></param>
|
||||||
|
protected void DisableCaching(Dictionary<string, string> parameters)
|
||||||
|
{
|
||||||
|
parameters.Add("disablecachetoken", DateTime.UtcNow.Ticks.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,6 +41,8 @@ public override Uri BuildRequestUrl()
|
|||||||
parameters.Add("username", Username);
|
parameters.Add("username", Username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisableCaching(parameters);
|
||||||
|
|
||||||
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(apiUrl, UriKind.Absolute);
|
return new Uri(apiUrl, UriKind.Absolute);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public override Uri BuildRequestUrl()
|
|||||||
};
|
};
|
||||||
|
|
||||||
base.AddPagingParameters(parameters);
|
base.AddPagingParameters(parameters);
|
||||||
|
base.DisableCaching(parameters);
|
||||||
|
|
||||||
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var apiUrl = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(apiUrl, UriKind.Absolute);
|
return new Uri(apiUrl, UriKind.Absolute);
|
||||||
|
@ -31,6 +31,7 @@ public override Uri BuildRequestUrl()
|
|||||||
};
|
};
|
||||||
|
|
||||||
base.AddPagingParameters(parameters);
|
base.AddPagingParameters(parameters);
|
||||||
|
base.DisableCaching(parameters);
|
||||||
|
|
||||||
var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(uristring, UriKind.Absolute);
|
return new Uri(uristring, UriKind.Absolute);
|
||||||
|
@ -32,6 +32,7 @@ public override Uri BuildRequestUrl()
|
|||||||
};
|
};
|
||||||
|
|
||||||
base.AddPagingParameters(parameters);
|
base.AddPagingParameters(parameters);
|
||||||
|
base.DisableCaching(parameters);
|
||||||
|
|
||||||
var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
var uristring = LastFm.FormatApiUrl(Method, Auth.ApiKey, parameters);
|
||||||
return new Uri(uristring, UriKind.Absolute);
|
return new Uri(uristring, UriKind.Absolute);
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Api\AlbumApi.cs" />
|
<Compile Include="Api\AlbumApi.cs" />
|
||||||
<Compile Include="Api\ArtistApi.cs" />
|
<Compile Include="Api\ArtistApi.cs" />
|
||||||
<Compile Include="Api\Commands\AlbumApi\GetAbumInfoCommand.cs" />
|
<Compile Include="Api\Commands\AlbumApi\GetAlbumInfoCommand.cs" />
|
||||||
<Compile Include="Api\Commands\ArtistApi\GetArtistInfoCommand.cs" />
|
<Compile Include="Api\Commands\ArtistApi\GetArtistInfoCommand.cs" />
|
||||||
<Compile Include="Api\Commands\GetAsyncCommandBase.cs" />
|
<Compile Include="Api\Commands\GetAsyncCommandBase.cs" />
|
||||||
<Compile Include="Api\Commands\PostAsyncCommandBase.cs" />
|
<Compile Include="Api\Commands\PostAsyncCommandBase.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user