question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to get multipart/form-data from POST requests with requestInterceptor

See original GitHub issue

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Create a form with enctype="multipart/form-data", e.g. https://codesandbox.io/s/fervent-http-c24v7
  2. Open the page with puppeteer, add a request interceptor, add a file to the upload input and submit the form.
const puppeteer = require("puppeteer");

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setRequestInterception(true);

  page.on("request", (interceptedRequest) => {
    if (interceptedRequest.method() === "POST") {
      console.log(interceptedRequest.postData());
    }

    interceptedRequest.continue();
  });

  await page.goto("https://c24v7.codesandbox.io/");
  const input = await page.$("#file_input");

  // a simple txt file with little just some dummy text
  await input.uploadFile("./file.txt");
  await page.click("#submit");
  
  await browser.close();
})().catch(console.error);

What is the expected result? According to me, the multipart/form-data should be available inside the request interceptor (requestInterceptor.postData()).

What happens instead? The requestInterceptor.postData() is undefined. Interestingly, when using puppeteer-firefox, this very same code works properly and the postData() is available inside the requestInterceptor.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ivansiedercommented, Oct 27, 2020

I’ve switched to Firefox @rgoldstein01

0reactions
stale[bot]commented, Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot send form data with axios when using interceptors
My 3rd try was to add a request interceptor by modifying config (add formData ) before request is sent but I never access...
Read more >
Axios - npm
Using multipart/form-data format. FormData; Automatic serialization. Files Posting; HTML Form Posting; Progress capturing ...
Read more >
How can I make a multipart/form-data POST request in VQL
How can I make a multipart/form-data POST request in VQL. VQL can be used to make http requests using the http_client() plugin. While...
Read more >
Fuel HTTP Library with Kotlin - Baeldung
Support for basic HTTP verbs (GET, POST, DELETE, etc.) both asynchronous and blocking requests; Ability to download and upload a file (multipart ......
Read more >
dio | Dart Package - Pub.dev
A powerful Http client for Dart, which supports Interceptors, FormData, Request ... it may be `null` if the request can't reach to ///...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found