request.fetchPostData is useful when the postdata wasn't available when the request was intercepted, but it does have request data linked to it (this is when the incoming event field HasPostData is true). This should replace the existing request.postData API.
Suggested Solution (optional)
It should be something like this:
// FetchPostData returns the request post data, if any.
//
// If will attempt to fetch the data if it should have some but nothing is
// cached locally.
//
// This relies on PostDataEntries. It will only ever return the 0th entry. To
// retrieve the full list use PostDataEntries.
func (r *Request) FetchPostData() (string, error) {
if len(r.postDataEntries) > 0 {
return r.postDataEntries[0], nil
}
if r.hasPostData && len(r.postDataEntries) == 0 {
action := network.GetRequestPostData(r.getID())
pd, err := action.Do(cdp.WithExecutor(r.ctx, r.frame.page.session))
if err != nil {
return "", fmt.Errorf("getting postData: %w", err)
}
r.postDataEntries = []string{pd}
return pd, nil
}
return "", nil
}
I hesitate to add this in since we've got no use case for it.
Already existing or connected issues / PRs (optional)
Feature Description
request.fetchPostData
is useful when the postdata wasn't available when the request was intercepted, but it does have request data linked to it (this is when the incoming event fieldHasPostData
istrue
). This should replace the existingrequest.postData
API.Suggested Solution (optional)
It should be something like this:
I hesitate to add this in since we've got no use case for it.
Already existing or connected issues / PRs (optional)
No response