Comments (2)
Would you care to elaborate on what "but it's not working" refers to? :)
Sending HTTP requests which include a body (such as your POST
) requires the client to tell the server the expected length either via the Content-Length
header or via chunked transfer encoding (which is currently not supported). Also, the data you're sending appears to be formatted like HTML form data, so you need to specify the correct Content-Type
header like so:
$data = 'test=12345';
$request = $client->request(
'POST',
'http://respondto.it/bomber',
array(
'Content-Length' => strlen($data),
'Content-Type' => 'application/x-www-form-urlencoded'
)
);
$request->end($data);
from http-client.
As you can see in result, body wasn't received.
But it was my mistake. I forgot to add headers because i expected that Client will add necessary Headers. I suggest to add this to documentation.
Thank you.
from http-client.
Related Issues (20)
- Time Out Question HOT 1
- question regarding writing HOT 2
- Hanging connector HOT 1
- Unable to validate "1 " as chunk length header HOT 3
- strtolower() expects parameter 1 to be string, array given HOT 1
- Delay Request Connection HOT 6
- Error on "close" event HOT 8
- How to get the full response body? HOT 1
- [bug]Concurrent with more than 1000 requests. HOT 4
- client pool HOT 1
- Memory leak in SecureConnector HOT 4
- Integrate Server Sent event api (EventSource) or streaming HTTP api HOT 1
- Support detecting response body boundaries HOT 1
- Can this library be used in php-fpm mode? HOT 2
- Trying to POST multipart/form-data HOT 2
- Support for certificate authentication when using HttpClientAdapter HOT 1
- Stop streaming half-way. HOT 1
- Support HTTP upgrades (WebSocket etc.) HOT 1
- is $loop->run(); blocking? HOT 4
- Heads up! Development focus on react/http
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-client.