R
R
recloudor2015-12-29 10:59:07
Computer networks
recloudor, 2015-12-29 10:59:07

Is it possible to fake Content-length?

I did not find info on the Internet.
Is the header with content-length sent by the browser or how does it all happen?
For example, the server accepts a request for a file, is it safe to trust the content-length?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nazar Mokrinsky, 2015-12-29
@recloudor

If the Content-Length is greater than the actual body, then the web server will wait for data to be received and eventually timeout without waiting for all the data (or part of the next request will end up at the end of the body of the current one), if vice versa, then the end of the current request will end up in the beginning of the next one and the next request will fail.
That is, if you received a valid request, then Content-Length is the actual amount of data.
If you implement an HTTP server yourself, you need to check all this, but if you use a ready-made one, then in fact, yes, you can trust it.

V
Vladimir Martyanov, 2015-12-29
@vilgeforce

I think this can be easily checked with curl and manual header generation.

3
333Serega333 333Serega333, 2015-12-29
@333Serega333

$post_data = array(
    "end" => array("dateTime" => "2013-14-11T10:40:00.000-07:00"),  
    "start" => array("dateTime" => "2013-14-11T10:00:00.000-07:00"),  
    "summary" => "my_summary",
    "description" => "my_description"
);

$post_data = json_encode($post_data);
curl_setopt($ch2, CURLOPT_HTTPHEADER, array(  
   'Content-Type: application/json',  
   'Content-Length: ' . strlen($post_data),)  
 );

You can set the Content-Length value yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question