adrianstern has asked for the wisdom of the Perl Monks concerning the following question:

I'm playing with a simple chat room program

I need the server to sometimes do nothing, ie not reply to a request. If I do this I get an error from Apache

If I send a blank header the browser tries to download it as it's getting a non-executable file

can this in fact be done at all?

Replies are listed 'Best First'.
Re: no server response required (heartbeat http 204)
by Anonymous Monk on Nov 19, 2013 at 13:55 UTC

    I'm playing with a simple chat room program

    What program? What protocols does it use?

    I need the server to sometimes do nothing, ie not reply to a request. If I do this I get an error from Apache

    Well, don't do that then, or get apache to ignore it, or something else

    If I send a blank header the browser tries to download it as it's getting a non-executable file

    A "blank header" is nonsense , apache is probably fixing the headers for you so they're not blank (nonsense) anymore ... apache documents this

    can this in fact be done at all?

    Sure it can, if you learn about the internet you'll know the magic words

    $ perl -MCGI -e " my $q = CGI->new; print $q->header(qw/ -status 204 - +nph 1/) " HTTP/1.0 204 Server: cmdline Status: 204 Date: Tue, 19 Nov 2013 13:58:00 GMT Content-Type: text/html; charset=ISO-8859-1
Re: no server response required
by ww (Archbishop) on Nov 19, 2013 at 13:57 UTC

    ...and this relates to PM, how?

    Pls add code or sufficient detail to justify asking this question here, rather than on an Apache forum.

    And, not just BTW, you'll probably want to specify which Apache; the circumstances in which you want Apache to "sometimes do nothing", and the error you're seeing.

    It might also be wise to include a rationale for your desire -- IOW, why are you trying to do what, this way.

Re: no server response required
by locked_user sundialsvc4 (Abbot) on Nov 19, 2013 at 14:24 UTC

    (I am taking for granted that the OP is addressing a Perl-based CGI or FastCGI handler ... therefore, that the question is being asked in an appropriate venue.)

    It is my understanding that requests issued, at least to Apache, must be replied-to.   You might be able to use a different HTTP server, but actually, I think this is a requirement of the HTTP protocol.   (I'd be a little surprised if your browser didn’t get upset about it, too ...)

    Can you perhaps return 204 No Content?   (See:   this WikiPedia page...)   Now, you are fulfilling the handshake obligation of the protocol, but saying that there is nothing else to say.

Re: no server response required
by taint (Chaplain) on Nov 19, 2013 at 15:34 UTC
    Greetings.

    You might also be interested to know that Apache(2*) already does/provides this internally. Since I wrote, and use my own HTTPD, I don't use Apache as a rule. But I do keep a version on one of my servers for experimentation. Here's an example from the log:

    apache.null - - [19/Nov/2013:07:13:45 -0800] "OPTIONS * HTTP/1.0" 200 +- "-" "Apache/2.2.24 (...) (internal dummy connection)"
    So, as you can see. Pretty much any 2xx will suffice. But as noted by others, a 204 might be considered the most appropriate. :)

    HTH, and Best wishes.

    --Chris

    #!/usr/bin/perl -Tw
    use Perl::Always or die;
    my $perl_version = (5.12.5);
    print $perl_version;