private FaceClient(Uri baseUrl, string key, PipelineOptions options) { _options = options; _baseUrl = baseUrl; _keyHeader = new HttpHeader(s_keyHeaderName, key); _client = HttpPipeline.Create(options, SdkName, SdkVersion); }
public async Task HelloWorld() { var cancellation = new CancellationTokenSource(); var options = new HttpPipeline.Options(); HttpPipeline pipeline = HttpPipeline.Create(options, sdkName: "test", sdkVersion: "1.0"); using (HttpMessage message = pipeline.CreateMessage(options, cancellation: default)) { var uri = new Uri(@"https://raw.githubusercontent.com/Azure/azure-sdk-for-net/master/src/SDKs/Azure.Base/data-plane/Azure.Base.sln"); message.SetRequestLine(HttpVerb.Get, uri); message.AddHeader("Host", uri.Host); await pipeline.SendMessageAsync(message).ConfigureAwait(false); Response response = message.Response; if (response.Status == 200) { var reader = new StreamReader(response.ContentStream); string responseText = reader.ReadToEnd(); } else { throw new RequestFailedException(response); } } }
public FileUri(string file, PipelineOptions options = default) { if (options == default) { _options = new PipelineOptions(); } else { _options = options; } Pipeline = HttpPipeline.Create(_options, SdkName, SdkVersion); _baseUri = new Uri(file); }
public ConfigurationClient(string connectionString, HttpPipeline.Options options) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options; Pipeline = HttpPipeline.Create(_options, SdkName, SdkVersion); ParseConnectionString(connectionString, out _baseUri, out _credential, out _secret); }
public void Basics() { var options = new HttpPipeline.Options(); options.Transport = new MockTransport(500, 1); options.RetryPolicy = new CustomRetryPolicy(); var listener = new TestEventListener(); listener.EnableEvents(EventLevel.LogAlways); var pipeline = HttpPipeline.Create(options, "test", "1.0.0"); using (var message = pipeline.CreateMessage(options, cancellation: default)) { message.SetRequestLine(HttpVerb.Get, new Uri("https://contoso.a.io")); pipeline.SendMessageAsync(message).Wait(); Assert.AreEqual(1, message.Response.Status); var result = listener.ToString(); Assert.AreEqual(expected, result); } }