Home > Mobile >  Why Transfer-Encoding request header does not interpret correctly?
Why Transfer-Encoding request header does not interpret correctly?

Time:12-01

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:

<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.

CodePudding user response:

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

  • Related