The Question:
How do I get IO::Socket::SSL to accept a socket connection without sending headers to the browser which prevent me from providing my own HTTP headers.

The Problem:
I have an incredibly basic HTTPS server setup at this point, but it seems like at some point in my code (the included modules) headers are being provided back which aren't allowing me to specify my own HTTP headers. The result from doing the HEAD command with linux on my domain with https pulling from the server made below:
200 Assumed OK Client-Date: Fri, 12 Jun 2009 16:16:46 GMT Client-Peer: 174.120.41.194:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: ... Client-SSL-Cert-Subject: ... Client-SSL-Cipher: AES256-SHA Client-SSL-Warning: Peer certificate not verified

My Setup:
v5.8.8 built for i686-linux
(CentOS) Linux 2.6.28.9 #5 SMP Mon Mar 30 04:51:09 CDT 2009 i686 i686 i386 GNU/Linux
IO::Socket::SSL version 1.24


The Code:
#!/usr/bin/perl use strict; use IO::Socket::SSL; my ($sock, $s); $sock = IO::Socket::SSL->new( Listen => 5, LocalPort => 443, RemoteAddr => 'myip', LocalAddr => 'myip', Proto => 'tcp', SSL_verify_mode => 0x01, Reuse => 1, SSL_key_file => 'certs/keyfile', SSL_cert_file => 'certs/certfile.crt', SSL_ca_file => 'certs/bundle.ca-bundle' ); while (1) { while(($s = $sock->accept())) { print $s "Content-type: text/html\n\n"; $s->close(SSL_no_shutdown => 1); } } $sock->close();
What I think at this point:
I would expect either a broken page (browser rejecting the response), or a blank page with a mime type of text/html (since it apparently assumes 200 OK anyway). It really appears to me that at the point of accepting the connection this data is sent to the browser, and there really would be nothing I could do without modifying the modules used.

It would be great if anyone could help me figure out how to get the server to allow me to send my own HTTP response headers.

Sorry in advance if this post wasn't up to perlmonks.org standards.

In reply to IO::Socket::SSL HTTPS Headers by hostsentry

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.