adobe / experience-platform-postman-samples

MIT License
83 stars 142 forks source link

Update pre-request scripts to mitigate concurrent modification issue while removing blank headers #61

Closed dlh3 closed 1 year ago

dlh3 commented 1 year ago

Description

In Postman 10.7.1 for MacOS, pm.request.headers.each() fails when removing headers while iterating over them:

TypeError: Cannot read properties of undefined (reading 'value')

Using Request.forEachHeader() avoids that pitfall. Other options would be operating on pm.request.headers.members, or calling all() or map() before each(), since either would result in an independent list of headers.

For reference, Request.forEachHeader() internally calls pm.request.headers.all().each(callback).

Related Issue

62

Motivation and Context

Fixes a TypeError that breaks this collection.

How Has This Been Tested?

Manually and exhaustively with Postman.

Screenshots (if appropriate):

image image

Types of changes

Checklist: