Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why Transfer-Encoding request header does not interpret correctly?

Here is the PHP code for pg3.php:

<html>
<body>
<form method="post" action="pg3.php">
<h2><font color="red">::Welcome to Server1: 172.16.24.150::</font></h2>
<input type="text" name="user">
<input type="submit" value="Submit">
</body>
</html>

<?php

if(!empty($_POST["user"])){

  echo $_POST["user"];

}

?>

I sent the following request:

curl --data "8\r\nuser=mehran\r\n0\r\n" --header "Transfer-Encoding: chunked" "http://172.16.17.10/pg3.php"

I got the following response:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<html>
<body>
<form method="post" action="pg3.php">
<h2><font color="red">::Welcome to Server1: 172.16.24.150::</font></h2>
<input type="text" name="user">
<input type="submit" value="Submit">
</body>
</html>

As the above shows, user=meh is not in the response, while it must be there if Transfer-Encoding works correctly.

What’s the problem??
TNX.

>Solution :

See this example in the documentation:

You send a chunked POST with curl like this:

curl -H "Transfer-Encoding: chunked" -d "payload to send" http://example.com

You don’t need to try to create the chunked encoded payload yourself. In your case:

curl --data "user=mehran" --header "Transfer-Encoding: chunked" "http://172.16.17.10/pg3.php"

is enough for curl to send:

POST / HTTP/1.1
...
Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded

b
user=mehran
0

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading