Giter Site home page Giter Site logo

Comments (13)

Nyholm avatar Nyholm commented on May 27, 2024

Can you show us some minimal code here and also how you run it?

from httplug.

fbourigault avatar fbourigault commented on May 27, 2024

Also, do you have the involved CurlCommandFormatter.php line?

from httplug.

BenoitLeveque avatar BenoitLeveque commented on May 27, 2024

@fbourigault it's line 42

from httplug.

BenoitLeveque avatar BenoitLeveque commented on May 27, 2024
$request = $this->messageFactory->createRequest('POST', 'api_url');

$data = file_get_contents('foo.jpeg'); // content of the file
$builder = new MultipartStreamBuilder($this->streamFactory);
$builder->addResource('file', $data, ['headers' => ['Content-Type' => $file->getMimeType()], 'filename' => $file->getFilename()]);

$multipartStream = $builder->build();
$boundary = $builder->getBoundary();

$request = $request->withBody($multipartStream);
$request = $request->withHeader('Content-Type', 'multipart/form-data; boundary="'.$boundary.'"');

$response = $this->client->sendRequest($request);

You can put this code inside a symfony controller you should have the error.

from httplug.

fbourigault avatar fbourigault commented on May 27, 2024

Line 42 is: https://github.com/php-http/message/blob/master/src/Formatter/CurlCommandFormatter.php#L42

from httplug.

Nyholm avatar Nyholm commented on May 27, 2024

You are using the CurlClient. It is super fast but also very strict. You have forgotten to add a content-length header. You could use the Content-Length plugin to fix this.

from httplug.

fbourigault avatar fbourigault commented on May 27, 2024

The issue is about using the CurlCommandFormatter so it should happen even when not sending the request. I tried to reproduce it locally but it's working.
Which stream implementation are you using? zend, slim or guzzle?

from httplug.

Nyholm avatar Nyholm commented on May 27, 2024

Guzzle psr7.

I tried the code with curl - fail
Tried with guzzle - success
Tried with curl and content-length plugin - success.

But I might be wrong.

from httplug.

fbourigault avatar fbourigault commented on May 27, 2024

I tried without Symfony and without any client. It worked! I also have the Content-Length header set by the MultipartStreamBuilder.

from httplug.

BenoitLeveque avatar BenoitLeveque commented on May 27, 2024

I'm using guzzle with the symfony integration

here is my configuration :

httplug:
    classes:
        client: Http\Adapter\Guzzle6\Client
        message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
        uri_factory: Http\Message\UriFactory\GuzzleUriFactory
        stream_factory: Http\Message\StreamFactory\GuzzleStreamFactory

each of my clients use factory: 'httplug.factory.guzzle6'

My issue is only present when the profiler is enabled, the ProfilePlugin use a Formatter that use CurlCommandFormatter.

for a quick workaround i've disable the profile plugin and everything work fine

from httplug.

fbourigault avatar fbourigault commented on May 27, 2024

Which plugins are you using?

from httplug.

BenoitLeveque avatar BenoitLeveque commented on May 27, 2024

I'm using 3 plugins:

  • 'httplug.plugin.logger'
  • reference:
    id: 'app.httplug.plugin.base_uri'
  • 'httplug.plugin.authentication.customer'

from httplug.

joelwurtz avatar joelwurtz commented on May 27, 2024

This has been fixed in php-http/message#94

from httplug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.