简体   繁体   中英

400 Error when Trying to submit rails form via AJAX

Here's the setup:

  • Very simple form, just a name field, plus two ActiveStorage attachment fields square_image and landscape_image .
  • Both fields have direct_upload: true set.
  • If all form fields are filled out, including the files, the submit work exactly right, no problem.
  • However , if you fill out only the name field, leaving any of the file fields blank, I get an invalid_request every time.

This only happens in Safari .

The debug logs from nginx reveal client prematurely closed stream: only 548 out of 953 bytes of request body received .

It doesn't seem to be an nginx issue, because I get a similar experience locally via pow (the connection just hangs for a long time, presumably because pow is waiting for the data that never arrives).

Has anyone else experienced this, or have any ideas about how to debug this? I can't figure out where to go from here.

  • Rails 5.2.0
  • Safari 11.1 (13605.1.33.1.2)

This is indeed a bug in webkit. It has allegly been fixed but at this point in time, the bug still affects Safari. https://trac.webkit.org/changeset/230963/webkit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM