Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Http Client multipart request #32058 #32428

Merged
merged 2 commits into from
Apr 19, 2020
Merged

[7.x] Http Client multipart request #32058 #32428

merged 2 commits into from
Apr 19, 2020

Conversation

ljjackson
Copy link
Contributor

@ljjackson ljjackson commented Apr 17, 2020

This PR fixes #32058.

The issue has been raised because currently multipart requests can only be sent with the full multipart form parameters, like below:

<?php

use Illuminate\Support\Facades\Http;

Http::asMultipart()->post($url, [
   ['name' => 'key', 'contents' => 'value']
]);

This is not currently in line with the sending post requests via another bodyFormat, so this PR allows for both possibilities.

<?php

use Illuminate\Support\Facades\Http;

$file = fopen($path_to_file, 'r');

Http::attach('file', $file)->post($url, [
   ['name' => 'key', 'contents' => 'value'],
   'another_key' => 'value'
]);

- Adds functionality to parse multipart requests when sent as ['key' => 'value'].
- Adds tests to ensure that ['key' => 'value'] multipart requests and [['name' => 'key', 'contents' => 'value'] requests are sent in a non-breaking fashion.
@GrahamCampbell GrahamCampbell changed the title Http Client multipart request #32058 [7.x] Http Client multipart request #32058 Apr 17, 2020
@ljjackson ljjackson marked this pull request as draft April 17, 2020 20:53
@ljjackson ljjackson marked this pull request as ready for review April 17, 2020 20:54
@taylorotwell taylorotwell merged commit f9b85ba into laravel:7.x Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Http Client multipart request
2 participants