Skip to content

Commit

Permalink
Use Credentials.IsEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed Nov 6, 2024
1 parent b94bc22 commit 6bc31ab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ func (fs *FrameSession) updateHTTPCredentials(initial bool) error {
fs.logger.Debugf("NewFrameSession:updateHttpCredentials", "sid:%v tid:%v", fs.session.ID(), fs.targetID)

credentials := fs.page.browserCtx.opts.HTTPCredentials
if !initial || credentials != (Credentials{}) {
if !initial || !credentials.IsEmpty() {
return fs.networkManager.Authenticate(credentials)
}

Expand Down
4 changes: 2 additions & 2 deletions common/network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func (m *NetworkManager) onAuthRequired(event *fetch.EventAuthRequired) {
case m.attemptedAuth[rid]:
delete(m.attemptedAuth, rid)
res = fetch.AuthChallengeResponseResponseCancelAuth
case m.credentials != Credentials{}:
case !m.credentials.IsEmpty():
// TODO: remove requests from attemptedAuth when:
// - request is redirected
// - loading finished
Expand Down Expand Up @@ -721,7 +721,7 @@ func (m *NetworkManager) updateProtocolRequestInterception() error {
// Authenticate sets HTTP authentication credentials to use.
func (m *NetworkManager) Authenticate(credentials Credentials) error {
m.credentials = credentials
if credentials != (Credentials{}) {
if !credentials.IsEmpty() {
m.userReqInterceptionEnabled = true
}
if err := m.updateProtocolRequestInterception(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/browser_context_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestBrowserContextOptionsDefaultValues(t *testing.T) {
assert.Empty(t, opts.ExtraHTTPHeaders)
assert.Nil(t, opts.Geolocation)
assert.False(t, opts.HasTouch)
assert.Nil(t, opts.HTTPCredentials)
assert.True(t, opts.HTTPCredentials.IsEmpty())
assert.False(t, opts.IgnoreHTTPSErrors)
assert.False(t, opts.IsMobile)
assert.True(t, opts.JavaScriptEnabled)
Expand Down

0 comments on commit 6bc31ab

Please sign in to comment.