Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Handling XML content with HTTP::Daemon

by Matts (Deacon)
on Jul 09, 2002 at 12:31 UTC ( #180458=note: print w/replies, xml ) Need Help??

in reply to Handling XML content with HTTP::Daemon

Looks like you're forgetting to send headers. Try:
$c->send_response( "Content-type: text/xml+svg\r\n\r\n". $svg->xmlify() );

Replies are listed 'Best First'.
Re: Re: Handling XML content with HTTP::Daemon
by hackmare (Pilgrim) on Jul 09, 2002 at 14:10 UTC

    Thanks a lot for pointing out what should have been obvious!, that got me a long way towards my goal. Now I just need to cleanly get rid of the following footer which seems to get appended to my file each time, confusing the XML parsers:

    ...the response... <!-- my comments... followed by two offending lines. --> Date: Tue, 09 Jul 2002 13:17:37 GMT Server: libwww-perl-daemon/1.21

    When I go into HTTP::Daemon and comment out these two lines:

    #(from HTTP::Daemon line 563) sub send_basic_header { my $self = shift; return if $self->antique_client; $self->send_status_line(@_); #taken out print $self "Date: ", time2str(time), $CRLF; my $product = $self->daemon->product_tokens; #taken out print $self "Server: $product$CRLF" if $product; }

    then the offending footers dissapear. Do you know what these two footer lines do, and should they not be in the header rather than in the footer? I can't find any way to override them other than by removing them from the module.

    ps. you had the wrong mime type in your solution (just to be clear about that). The SVG mimetype is image/svg+xml

    $c->send_response( "Content-type: image/svg+xml\r\n\r\n". $svg->xmlify());

      Ah, HTTP::Daemon expects a result code too. So you need:
      $c->send_response( 200, "Content-type: image/svg+xml\r\n\r\n". $svg->xmlify() );

        Here was the problem...

        I needed to create an HTTP::Response object explicitly and assign it a return code, content, and header information.

        #new response object with default error values my $response = new HTTP::Response( 404,undef,undef,"404 - Not found." +); #assign values using obvious methods $response->header(Content_Length => $len); $response->header(Content_Type => "image/svg+xml"); $response->content($out); $response->code(200); $c->send_response($response);

        This works now.

        Thanks you all for the help.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://180458]
[choroba]: I have no idea :-( I used to post to, but they don't seem to feature "private" pictures in the free version now
[Discipulus]: dazz i'm not an experts but i think it would be possible
[Corion]: dazz: I think Image::Magick can "read" from an in-memory filehandle
[Corion]: choroba: No, some general admin discussion of how to handle (company) user accounts
[Discipulus]: might be it is necessary to pass the pic data like MIME::Base64:: encode( data..
[Discipulus]: if you have a jpeg data: or as wise Corion said IM ca n read directly your handle

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-03-27 07:58 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.