IMHO there should be a switch for nph

I tried to modify SOAP/Transport/HTTP.pm. Since I hardly have any experience at patching others' code, I thought it would be a good idea to ask for advice here instead of submitting a possibly wrong bug report/fix. Well, this is the original code of S::T::H::CGI::handle:

sub handle { my $self = shift->new; my $length = $ENV{'CONTENT_LENGTH'} || 0; if (!$length) { $self->response(HTTP::Response->new(411)) # LENGTH REQUIRED } elsif (defined $SOAP::Constants::MAX_CONTENT_SIZE && $length > $SO +AP::Constants::MAX_CONTENT_SIZE) { $self->response(HTTP::Response->new(413)) # REQUEST ENTITY TOO LAR +GE } else { my $content; binmode(STDIN); read(STDIN,$content,$length); $self->request(HTTP::Request->new( $ENV{'REQUEST_METHOD'} || '' => $ENV{'SCRIPT_NAME'}, HTTP::Headers->new(map {(/^HTTP_(.+)/i ? $1 : $_) => $ENV{$_}} k +eys %ENV), $content, )); $self->SUPER::handle; } # imitate nph- cgi for IIS (pointed by Murray Nesbitt) my $status = defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWA +RE'}=~/IIS/ ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' : 'Status:'; my $code = $self->response->code; binmode(STDOUT); print STDOUT "$status $code ", HTTP::Status::status_message($code), "\015\012", $self->response->headers_as_string, "\015\012", $self->response->content; }

And I applied these changes:

# imitate nph- cgi for IIS (pointed by Murray Nesbitt) - my $status = defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTW +ARE'}=~/IIS/ - ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' : 'Status:'; + my $status; + if ($self->{'nph'}) { + $status = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0'; + } else { + $status = defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWA +RE'}=~/IIS/ + ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' : 'Status:'; + } my $code = $self->response->code;

Plus, I added a nph function:

sub nph { my $self = shift; $self->{'nph'} = 1; return $self; }

So now, I just add a call to nph and I get a proper HTTP response:

SOAP::Transport::HTTP::CGI ->dispatch_to ('/home/hue/lang/perl/modules', 'HelloWorld') ->nph ->handle;

Do you monks thing it's ok to submit this? Thank you for your valuable input.

--
David Serrano


In reply to Re^2: SOAP::Lite and HTTP status line by Hue-Bond
in thread SOAP::Lite and HTTP status line by Hue-Bond

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.