Skip to content

Commit

Permalink
fix: route.continue should not change multipart form data body
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeIwaki committed Jun 22, 2024
1 parent fbac8fd commit f64152b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/integration/page/request_continue_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

RSpec.describe 'request#continue' do
it 'should work', sinatra: true do
with_page do |page|
page.route('**/*', -> (route, _) { route.continue })
page.goto(server_empty_page)
end
end

it 'continue should not change multipart/form-data body', sinatra: true do
with_page do |page|
page.goto(server_empty_page)
promise = Concurrent::Promises.resolvable_future
sinatra.post('/upload') do
content_type 'text/plain'
promise.fulfill(params[:file][:tempfile].read)
'done'
end

page.route('**/*', -> (route, _) { route.continue })

status = page.evaluate(<<~JAVASCRIPT)
async () => {
const newFile = new File(['file content'], 'file.txt');
const formData = new FormData();
formData.append('file', newFile);
const response = await fetch('/upload', {
method: 'POST',
credentials: 'include',
body: formData,
});
return response.status;
}
JAVASCRIPT
expect(status).to eq(200)
expect(promise.value!).to eq('file content')
end
end
end

0 comments on commit f64152b

Please sign in to comment.