1

I am writing a Perl HTTP server using HTTP::Daemon. My Perl client is sending a HEAD request to the server to get the content length of the file which IO have to GET later.

My problem is that I am not able to generate a custom header and send it back to the client.

I can send back basic HTTP headers using $c->send_basic_header, but as soon as I try to send specific headers using $c->send_header( $field1, $value1, $field2, $value2, ... ) it does not work.

I am not able to understand what is the problem.

The headers which I am trying to send is

$c->send_header('Content-Type','image/jpeg','Cotent-Length','56360','Accept-Ranges','bytes')

I am new to Perl, so please help me understand how to do this.

3
  • 1
    What do you mean by "it does not work"? Commented Nov 9, 2014 at 17:59
  • It does not work mean that my client is not getting these values in the response off the head request. Commented Nov 9, 2014 at 18:01
  • Okay, so it is getting the basic headers (Server and Date) but nothing else? Commented Nov 9, 2014 at 18:05

1 Answer 1

1

You don't show your code, but do you realise that you need to send_basic_header as well as send_header?

Your code should look like this

$c->send_basic_header;
$c->send_header(
    'Content-Type'   => 'image/jpeg',
    'Content-Length' => '56360',
    'Accept-Ranges'  => 'bytes',
);
$c->send_crlf;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.