You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by willems Luc <wi...@pandora.be> on 2001/04/14 13:43:35 UTC

Unwanted "\n" in output

		Hello everybody ,

I have some Apache::ASP scripts that work like a XML::RPC . The idea is to 
send some XML request and the response will be an answer in XML that can be 
used by the client software.

One of my scrips has a problem that in the response , 7  times a '\n' 
charecter is put before the actual XML text (seen by using ethereal ). This 
confuses my clients XML parser (M$ parser ).
I don't know where these characters come from. The ouput i generated doesn't 
have it. I already tryed Response->Binarywrite and flushing but this doesn't 
do the trick.
Does anybody know where this comes from ?

		greetings,
		luc



Re: Unwanted "\n" in output

Posted by Andrew Ho <an...@tellme.com>.
Hello,

WL>One of my scrips has a problem that in the response , 7 times a '\n'
WL>charecter is put before the actual XML text (seen by using ethereal ).
WL>This confuses my clients XML parser (M$ parser ).

Actually, I think you are misdiagnosing your problem. The "7\n" that you
are seeing in your packet sniff sounds like a chunked Transfer-Encoding
byte size (check RFC 2616, the HTTP 1.1 specification, and read up on
chunked Transfer-Encoding). This would be perfectly normal in the case
that Apache doesn't know the Content-Length to send (which for scripts, it
won't unless you set it yourself).

Humbly,

Andrew

----------------------------------------------------------------------
Andrew Ho               http://www.tellme.com/       andrew@tellme.com
Engineer                   info@tellme.com          Voice 650-930-9062
Tellme Networks, Inc.       1-800-555-TELL            Fax 650-930-9101
----------------------------------------------------------------------


Re: Unwanted "\n" in output

Posted by Joshua Chamas <jo...@chamas.com>.
willems Luc wrote:
> 
>                 Hello everybody ,
> 
> I have some Apache::ASP scripts that work like a XML::RPC . The idea is to
> send some XML request and the response will be an answer in XML that can be
> used by the client software.
> 
> One of my scrips has a problem that in the response , 7  times a '\n'
> charecter is put before the actual XML text (seen by using ethereal ). This
> confuses my clients XML parser (M$ parser ).
> I don't know where these characters come from. The ouput i generated doesn't
> have it. I already tryed Response->Binarywrite and flushing but this doesn't
> do the trick.
> Does anybody know where this comes from ?
> 

Like Ged said, check out your <% %>, but also if you want to kill
leading white space globally, you might post process your output
in your global.asa with Script_OnFlush:

sub Script_OnFlush {
   my $out_ref = $Response->{BinaryRef};
   $$out_ref =~ s/^\s+(\<\?xml)/$1/s
}

Then set PerlSetVar BufferingOn 1 so that flush will only be called
once per script.

--Josh

_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: Unwanted "\n" in output

Posted by "G.W. Haywood" <ge...@www.jubileegroup.co.uk>.
Hi there,

On Sat, 14 Apr 2001, willems Luc wrote:

> I have some Apache::ASP scripts that work like a XML::RPC
[snip]
> One of my scrips has a problem that in the response , 7  times a '\n' 
> charecter is put before the actual XML text

Have you got some <% # comments %> in a template or something like that?
Sometimes you have to fiddle with the exact location of the <% and %> tags
to get the whitespace just right.

HTH

73,
Ged.