How to use the @azure/ms-rest-js.HttpHeaders function in @azure/ms-rest-js

To help you get started, we’ve selected a few @azure/ms-rest-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / storage / storage-BatchRequest.ts View on Github external
public getMultipartContentType(): string {
    return this.multipartContentType;
  }

  public getSubRequests(): Map {
    return this.subRequests;
  }
}

class BatchRequestAssemblePolicy extends BaseRequestPolicy {
  private batchRequest: InnerBatchRequest;
  private readonly dummyResponse: HttpOperationResponse = {
    request: new WebResource(),
    status: 200,
    headers: new HttpHeaders()
  };;

  constructor(
    batchRequest: InnerBatchRequest,
    nextPolicy: RequestPolicy,
    options: RequestPolicyOptions
  ) {
    super(nextPolicy, options);

    this.batchRequest = batchRequest;
  }

  public async sendRequest(request: WebResource): Promise {
    await this.batchRequest.appendSubRequestToBody(request);

    return this.dummyResponse; // Intercept request from going to wire
github Azure / azure-sdk-for-js / test / azureServiceClientTests.ts View on Github external
it("Poll: 204", async () => {
            const serviceClient: AzureServiceClient = createServiceClient([
              {
                status: 200,
                headers: new HttpHeaders({
                  "location": "https://fake.azure.com/longRunningOperation2"
                })
              },
              {
                status: 204
              }
            ]);
            const httpRequest = new WebResource("https://fake.azure.com/longRunningOperation", "PATCH");
            await msAssert.throwsAsync(
              serviceClient.sendLongRunningRequest(httpRequest),
              new Error(`The response with status code 204 from polling for long running operation url "https://fake.azure.com/longRunningOperation2" is not valid.`));
          });
        });
github Azure / azure-sdk-for-js / test / lroPollStrategyTests.ts View on Github external
it("with no AzureServiceClient.longRunningOperationRetryTimeout value and no retry-after header", function () {
      const azureServiceClient = new AzureServiceClient(new TokenCredentials("my-fake-token"));
      const previousResponse: HttpOperationResponse = {
        request: new WebResource(),
        status: 200,
        headers: new HttpHeaders()
      };
      assert.strictEqual(getDelayInSeconds(azureServiceClient, previousResponse), 30);
    });
github Azure / azure-sdk-for-js / test / azureServiceClientTests.ts View on Github external
sendRequest(httpRequest: WebResource): Promise {
        const response: HttpResponse | undefined = responses.shift();
        if (!response) {
          throw new Error("Not enough responses provided for test.");
        }
        return Promise.resolve({
          request: httpRequest,
          status: response.status,
          headers: response.headers || new HttpHeaders(),
          bodyAsText: typeof response.body === "string" ? response.body : JSON.stringify(response.body),
          parsedBody: response.body
        });
      }
    },
github Azure / ms-rest-nodeauth / test / credentials / msiVmTokenCredentialTests.ts View on Github external
sendRequest: async (req: WebResource): Promise => {
        if (error === undefined && isMatch(req, expectedRequestHeaders)) {
          const httpResponse: HttpOperationResponse = {
            request: req,
            status: 200,
            headers: new HttpHeaders(),
            bodyAsText: JSON.stringify(response)
          };
          return Promise.resolve(httpResponse);
        } else {
          return Promise.reject(error);
        }
      }
    };
github Azure / ms-rest-nodeauth / test / credentials / msiAppServiceTokenCredentialTests.ts View on Github external
sendRequest: async (request: WebResource): Promise => {
        if (error === undefined) {
          const httpResponse: HttpOperationResponse = {
            request: request,
            status: 200,
            headers: new HttpHeaders(),
            bodyAsText: JSON.stringify(response)
          };
          return Promise.resolve(httpResponse);
        } else {
          return Promise.reject(error);
        }
      }
    };
github Azure / azure-sdk-for-js / sdk / storage / storage-queue / src / policies / TokenCredentialPolicy.ts View on Github external
protected signRequest(request: WebResource): WebResource {
    if (!request.headers) {
      request.headers = new HttpHeaders();
    }
    request.headers.set(
      HeaderConstants.AUTHORIZATION,
      `${this.authorizationScheme} ${this.tokenCredential.token}`
    );
    return request;
  }
}
github Azure / azure-sdk-for-js / sdk / storage / storage-policies / TokenCredentialPolicy.ts View on Github external
protected signRequest(request: WebResource): WebResource {
    if (!request.headers) {
      request.headers = new HttpHeaders();
    }
    request.headers.set(
      HeaderConstants.AUTHORIZATION,
      `${this.authorizationScheme} ${this.tokenCredential.token}`
    );
    return request;
  }
}