Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sdk/core/Azure.Core/src/HttpHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,19 @@ public static class Names
/// Returns. <code>"If-Unmodified-Since"</code>
/// </summary>
public static string IfUnmodifiedSince => "If-Unmodified-Since";
/// <summary>
/// Returns. <code>"Referer"</code>
/// </summary>
public static string Referer => "Referer";
/// <summary>
/// Returns. <code>"Host"</code>
/// </summary>
public static string Host => "Host";

internal static string Referer => "Referer";
internal static string Host => "Host";
/// <summary>
/// Returns <code>"Content-Disposition"</code>
/// </summary>
public static string ContentDisposition => "Content-Disposition";
}

#pragma warning disable CA1034 // Nested types should not be visible
Expand Down
4 changes: 3 additions & 1 deletion sdk/core/Azure.Core/src/RequestContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using System.Threading;
using System.Buffers;
using System.Collections.Generic;

namespace Azure.Core
{
Expand Down Expand Up @@ -105,7 +106,8 @@ public override void WriteTo(Stream stream, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var read = _stream.Read(buffer, 0, buffer.Length);
if (read == 0) { break; }
if (read == 0)
{ break; }
cancellationToken.ThrowIfCancellationRequested();
stream.Write(buffer, 0, read);
}
Expand Down
29 changes: 29 additions & 0 deletions sdk/core/Azure.Core/src/Shared/BatchConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.Core
{
/// <summary>
/// Constants used by the batching APIs.
/// </summary>
internal static class BatchConstants
{
public const int KB = 1024;
public const int NoStatusCode = 0;
public const int RequestBufferSize = KB;
public const int ResponseLineSize = 4 * KB;
public const int ResponseBufferSize = 16 * KB;

public const string XmsVersionName = "x-ms-version";
public const string XmsClientRequestIdName = "x-ms-client-request-id";
public const string XmsReturnClientRequestIdName = "x-ms-return-client-request-id";
public const string ContentIdName = "Content-ID";
public const string ContentLengthName = "Content-Length";

public const string MultipartContentTypePrefix = "multipart/mixed; boundary=";
public const string RequestContentType = "Content-Type: application/http";
public const string RequestContentTransferEncoding = "Content-Transfer-Encoding: binary";
public const string BatchSeparator = "--";
public const string HttpVersion = "HTTP/1.1";
}
}
27 changes: 27 additions & 0 deletions sdk/core/Azure.Core/src/Shared/BatchErrors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core.Pipeline;

namespace Azure.Core
{
/// <summary>
/// Errors raised by the batching APIs.
/// </summary>
internal static class BatchErrors
{
public static InvalidOperationException InvalidBatchContentType(string contentType) =>
new InvalidOperationException($"Expected {HttpHeader.Names.ContentType} to start with {BatchConstants.MultipartContentTypePrefix} but received {contentType}");

public static InvalidOperationException InvalidHttpStatusLine(string statusLine) =>
new InvalidOperationException($"Expected an HTTP status line, not {statusLine}");

public static InvalidOperationException InvalidHttpHeaderLine(string headerLine) =>
new InvalidOperationException($"Expected an HTTP header line, not {headerLine}");

public static RequestFailedException InvalidResponse(ClientDiagnostics clientDiagnostics, Response response, Exception innerException) =>
clientDiagnostics.CreateRequestFailedExceptionWithContent(response, message: "Invalid response", innerException: innerException);

}
}
Loading