XML over HTTPS

Discussion in 'XML' started by chitu, May 11, 2005.

  1. chitu

    chitu Guest

    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.
     
    chitu, May 11, 2005
    #1
    1. Advertising

  2. chitu () 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?

    --

    This space not for rent.
     
    Malcolm Dew-Jones, May 11, 2005
    #2
    1. Advertising

  3. chitu

    chitu Guest

    Malcolm Dew-Jones wrote:
    > chitu () 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.



    >
    > : 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?
    >
    > --
    >
    > This space not for rent.
     
    chitu, May 11, 2005
    #3
  4. On Wed, 11 May 2005, Malcolm Dew-Jones wrote:

    > 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
     
    Alan J. Flavell, May 11, 2005
    #4
  5. chitu () wrote:

    : Malcolm Dew-Jones wrote:
    : > chitu () 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").

    --

    This space not for rent.
     
    Malcolm Dew-Jones, May 11, 2005
    #5
  6. In article <>,
    chitu <> wrote:

    [...]

    % 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.
    --

    Patrick TJ McPhee
    North York Canada
     
    Patrick TJ McPhee, May 12, 2005
    #6
  7. chitu

    Ian Wilson Guest

    chitu wrote:
    >>: I am having trouble sending XML data over HTTPS.
    >>
    >>: Clients connect to server using SSL_XXX system calls
    >>: and server is running apache.


    > 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).
     
    Ian Wilson, May 12, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luther Baker

    xml transform over https

    Luther Baker, Dec 9, 2003, in forum: XML
    Replies:
    4
    Views:
    569
    Luther Baker
    Dec 9, 2003
  2. kryptson2004

    Sample C for sending SOAP XML over HTTPS

    kryptson2004, Sep 11, 2009, in forum: C Programming
    Replies:
    0
    Views:
    660
    kryptson2004
    Sep 11, 2009
  3. Axel
    Replies:
    8
    Views:
    1,273
    Adrienne Boswell
    Apr 27, 2009
  4. jotto
    Replies:
    4
    Views:
    443
    jotto
    Oct 2, 2006
  5. brad
    Replies:
    4
    Views:
    164
Loading...

Share This Page