send always

This commit is contained in:
Yury Semikhatsky 2024-05-29 17:19:08 -07:00
parent 030699cd92
commit 88baf04920
5 changed files with 29 additions and 29 deletions

View file

@ -571,7 +571,7 @@ Whether to emulate network being offline. Defaults to `false`. Learn more about
- `username` <[string]>
- `password` <[string]>
- `origin` ?<[string]> Restrain sending http credentials on specific origin (scheme://host:port).
- `send` ?<[WhenToSend]<"unauthorized"|"immediately">> This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
- `send` ?<[WhenToSend]<"unauthorized"|"always">> This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

View file

@ -159,7 +159,7 @@ export abstract class APIRequestContext extends SdkObject {
}
const credentials = this._getHttpCredentials(requestUrl);
if (credentials?.send === 'immediately')
if (credentials?.send === 'always')
setBasicAuthorizationHeader(headers, credentials);
const method = params.method?.toUpperCase() || 'GET';

View file

@ -13384,11 +13384,11 @@ export interface BrowserType<Unused = {}> {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
};
/**
@ -14922,11 +14922,11 @@ export interface AndroidDevice {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
};
/**
@ -15654,11 +15654,11 @@ export interface APIRequest {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
};
/**
@ -16812,11 +16812,11 @@ export interface Browser extends EventEmitter {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
};
/**
@ -17710,11 +17710,11 @@ export interface Electron {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
};
/**
@ -20379,11 +20379,11 @@ export interface HTTPCredentials {
/**
* This option only applies to the requests sent from corresponding {@link APIRequestContext} and does not affect
* requests sent from the browser. `'immediately'` - `Authorization` header with basic authentication credentials will
* be sent with the first API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized)
* response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
* requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be
* sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response
* with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.
*/
send?: "unauthorized"|"immediately";
send?: "unauthorized"|"always";
}
export interface Geolocation {

View file

@ -438,7 +438,7 @@ it('should return error with wrong credentials', async ({ context, server }) =>
it('should support HTTPCredentials.sendImmediately for newContext', async ({ contextFactory, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30534' });
const context = await contextFactory({
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'immediately' }
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'always' }
});
{
const [serverRequest, response] = await Promise.all([
@ -462,7 +462,7 @@ it('should support HTTPCredentials.sendImmediately for newContext', async ({ con
it('should support HTTPCredentials.sendImmediately for browser.newPage', async ({ contextFactory, server, browser }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30534' });
const page = await browser.newPage({
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'immediately' }
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'always' }
});
{
const [serverRequest, response] = await Promise.all([

View file

@ -157,7 +157,7 @@ it('should support WWW-Authenticate: Basic', async ({ playwright, server }) => {
it('should support HTTPCredentials.sendImmediately', async ({ playwright, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30534' });
const request = await playwright.request.newContext({
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'immediately' }
httpCredentials: { username: 'user', password: 'pass', origin: server.PREFIX.toUpperCase(), send: 'always' }
});
{
const [serverRequest, response] = await Promise.all([