This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task TestNoCache(string host) | |
{ | |
var clientHandler = new WebRequestHandler(); | |
clientHandler.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default); | |
var client = new HttpClient(clientHandler) { BaseAddress = new Uri(host) }; | |
var response = await client.GetAsync("/CacheableResource"); | |
var request = new HttpRequestMessage() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void TestBigDownload(string host) | |
{ | |
var httpclient = new HttpClient() { BaseAddress = new Uri(host) }; | |
var stream = httpclient.GetStreamAsync("pullbigresource").Result; | |
var bytes = new byte[10000]; | |
var bytesread = stream.Read(bytes, 0, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void HttpMessageContent_from_a_file() | |
{ | |
var stream = | |
this.GetType().Assembly.GetManifestResourceStream("ClientSamples.StaticContent.HttpResponseMessage.txt"); | |
var content = new StreamContent(stream); | |
var contentType = new MediaTypeHeaderValue("application/http"); | |
contentType.Parameters.Add(new NameValueHeaderValue("msgtype", "response")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tmds:DataSource> | |
<tmds:HttpRequest url="/desktop/{dataset}/documents/quote/{id}"> | |
</tmds:HttpRequest> | |
</tmds:DataSource> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
========================================================== | |
GET http://birch:1001/ HTTP/1.1 | |
User-Agent: Fiddler | |
Host: birch:1001 | |
GET http://birch:1001/speakers HTTP/1.1 | |
User-Agent: Fiddler | |
Host: birch:1001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Web.Http; | |
using System.Web.Http.Owin; | |
using Microsoft.Owin; | |
using Microsoft.Owin.BuilderProperties; | |
using Microsoft.Owin.Host.HttpListener; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CollectionJsonContent : HttpContent | |
{ | |
private readonly MemoryStream _memoryStream = new MemoryStream(); | |
public CollectionJsonContent(Collection collection) | |
{ | |
var serializerSettings = new JsonSerializerSettings | |
{ | |
NullValueHandling = NullValueHandling.Ignore, | |
Formatting = Newtonsoft.Json.Formatting.Indented, | |
ContractResolver = new CamelCasePropertyNamesContractResolver() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FORM method="POST" action="http://example.com/whatever-I-dont-care"> | |
<INPUT type="text" name="value1" value="default1"/> | |
<INPUT type="text" name="value2" value="default2"/> | |
<FORM> | |
<LINK rel="http://tavis.ca/rels/form" method="POST" href="http://example.com/whatever-I-dont-care"> | |
<INPUT type="text" name="value1" value="default1"/> | |
<INPUT type="text" name="value2" value="default2"/> | |
<LINK> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.Routes.MapHttpRoute( | |
name: "TreeApi", | |
routeTemplate: "tree/{*path}", | |
defaults: null, | |
constraints: null, | |
handler: new ApiRouter("", new Uri("http://localhost:64921/tree")).To<FooController>()); | |
config.Routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ask the server for a password challenge string | |
var requestId = CryptographicBuffer.EncodeToHexString(CryptographicBuffer.GenerateRandom(4)); | |
var challengeResponse = await _httpClient.GetAsync(_clientBaseUrl + "GetPasswordChallenge?requestId=" + requestId); | |
challengeResponse.EnsureSuccessStatusCode(); | |
var challengeEncoded = await challengeResponse.Content.ReadAsAsync<string>(); | |
var challengeBuffer = CryptographicBuffer.DecodeFromHexString(challengeEncoded); | |
// Use HMAC_SHA512 hash to encode the challenge string using the password being authenticated as the key. | |
var provider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha512); |