XML over HTTPS

C

chitu

I am having trouble sending XML data over HTTPS.

Clients connect to server using SSL_XXX system calls
and server is running apache.

This is my whole script.

#!/usr/bin/perl -w

print "Content-Type: text/xml\n\n";
print "asdf\n\n";

When clients tries to read the content they dont see anything beyond
"content-type: text/xml".

Appreciate your help on this.

Thanks.
 
M

Malcolm Dew-Jones

chitu ([email protected]) wrote:
: I am having trouble sending XML data over HTTPS.

: Clients connect to server using SSL_XXX system calls
: and server is running apache.

: This is my whole script.

: #!/usr/bin/perl -w

: print "Content-Type: text/xml\n\n";
: print "asdf\n\n";

That data isn't xml, maybe that's the problem.

: When clients tries to read the content they dont see anything beyond
: "content-type: text/xml".

What do you mean? A person would not normally see the content-type:
header. Do you mean that some program you're running doesn't receive any
data after that header?
 
C

chitu

Malcolm said:
chitu ([email protected]) wrote:
: I am having trouble sending XML data over HTTPS.

: Clients connect to server using SSL_XXX system calls
: and server is running apache.

: This is my whole script.

: #!/usr/bin/perl -w

: print "Content-Type: text/xml\n\n";
: print "asdf\n\n";

That data isn't xml, maybe that's the problem.

I was trying to keep things simple.
The actual script is

#!/usr/bin/perl -w
print "Content-type: text/xml\n\n";
print <<"EOF";
<?xml version="1.0" encoding="ISO-8859-1"?>
<Response Type="Transaction">
<ErrNo>10</ErrNo>
</Response>
EOF

In my client program after I read the content using SSL_read (xml
parsing will
be done down the line) I print the content and I dont see anything
beyond
"Content-type: text/xml".
Basically I dont see anything after the \n\n.If I remove them I get 404
Error.
 
A

Alan J. Flavell

Each line break is supposed to be the two character sequence "\r\n" (i.e.
Carriage-return Line-feed, normally "\r\n" will do that in perl,

What \r and \n represent in Perl is patform-dependent. If you mean
precisely carriage return and linefeed, then you better code what you
mean, i.e \012 and \015.

There's a Perl FAQ about this issue.
though on some hardware you might need something else).

If you do it right then that problem disappears. (Well, there's also
the problem of EBCDIC-based platforms...)
Perhaps that makes a difference.

That depends on whether the script is constructing a CGI response, or
an HTTP response.

CGI responses are governed by the CGI specification (now an
informational RFC) and addressed by Perlfaq9. They accept the
platform's own newline representation (it's the server's job to
construct a protocol-conforming HTTP response based on them).

HTTP responses are governed by RFC2616 and do indeed call for CRLF
as the newline representation, irrespective of platform.

Ref: http://perlpod.com/5.9.1/pod/perlfaq9.html
"What is the correct form of response from a CGI script?"

(I have to declare an interest, but that was written after an
intensive peer review ;-)

all the best
 
M

Malcolm Dew-Jones

chitu ([email protected]) wrote:

: Malcolm Dew-Jones wrote:
: > chitu ([email protected]) wrote:
: > : I am having trouble sending XML data over HTTPS.
: >
: > : Clients connect to server using SSL_XXX system calls
: > : and server is running apache.
: >
: > : This is my whole script.
: >
: > : #!/usr/bin/perl -w
: >
: > : print "Content-Type: text/xml\n\n";
: > : print "asdf\n\n";
: >
: > That data isn't xml, maybe that's the problem.

: I was trying to keep things simple.
: The actual script is

: #!/usr/bin/perl -w
: print "Content-type: text/xml\n\n";
: print <<"EOF";
: <?xml version="1.0" encoding="ISO-8859-1"?>
: <Response Type="Transaction">
: <ErrNo>10</ErrNo>
: </Response>
: EOF

: In my client program after I read the content using SSL_read (xml
: parsing will
: be done down the line) I print the content and I dont see anything
: beyond
: "Content-type: text/xml".
: Basically I dont see anything after the \n\n.If I remove them I get 404
: Error.

Each line break is supposed to be the two character sequence "\r\n" (i.e.
Carriage-return Line-feed, normally "\r\n" will do that in perl, though on
some hardware you might need something else).

Perhaps that makes a difference.

(and the end of header would be written "\r\n\r\n").
 
P

Patrick TJ McPhee

[...]

% I was trying to keep things simple.
% The actual script is
%
% #!/usr/bin/perl -w
% print "Content-type: text/xml\n\n";
% print <<"EOF";
% <?xml version="1.0" encoding="ISO-8859-1"?>
% <Response Type="Transaction">
% <ErrNo>10</ErrNo>
% </Response>
% EOF
%
% In my client program after I read the content using SSL_read (xml
% parsing will
% be done down the line) I print the content and I dont see anything
% beyond
% "Content-type: text/xml".

Did you try calling SSL_read again? Perhaps it's not getting everything
the first time.
 
I

Ian Wilson

The actual script is

#!/usr/bin/perl -w
print "Content-type: text/xml\n\n";
print <<"EOF";
<?xml version="1.0" encoding="ISO-8859-1"?>
<Response Type="Transaction">
<ErrNo>10</ErrNo>
</Response>
EOF

In my client program after I read the content using SSL_read (xml
parsing will be done down the line) I print the content and I dont see anything
beyond "Content-type: text/xml". Basically I dont see anything after the \n\n.

What happens when you point a web browser at the URL?
What happens when you point wget at the URL?
wget -S -O - https://localhost/cgi-bin/yourscript.pl
If I remove them I get 404 Error.

Your script is then no longer emitting valid HTTP headers, so Apache
will report an error (should be a 500 not a 404).

Have you tried writing a simple server using SOAP::Lite? You could then
protoype the client using Perl SOAP::Lite (or at least use a perl client
to verify correct server operation).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,843
Latest member
WizcraftEntertainmentAgen

Latest Threads

Top