XML over HTTPS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chitu

    XML over HTTPS

    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.

  • Malcolm Dew-Jones

    #2
    Re: XML over HTTPS

    chitu (cperiyak@gmail .com) 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.

    Comment

    • chitu

      #3
      Re: XML over HTTPS


      Malcolm Dew-Jones wrote:[color=blue]
      > chitu (cperiyak@gmail .com) 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.[/color]

      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="Transacti on">
      <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.


      [color=blue]
      >
      > : When clients tries to read the content they dont see anything[/color]
      beyond[color=blue]
      > : "content-type: text/xml".
      >
      > What do you mean? A person would not normally see the content-type:[/color]
      [color=blue]
      > header. Do you mean that some program you're running doesn't receive[/color]
      any[color=blue]
      > data after that header?
      >
      > --
      >
      > This space not for rent.[/color]

      Comment

      • Malcolm Dew-Jones

        #4
        Re: XML over HTTPS

        chitu (cperiyak@gmail .com) wrote:

        : Malcolm Dew-Jones wrote:
        : > chitu (cperiyak@gmail .com) 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="Transacti on">
        : <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.

        Comment

        • Alan J. Flavell

          #5
          Re: XML over HTTPS

          On Wed, 11 May 2005, Malcolm Dew-Jones wrote:
          [color=blue]
          > 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,[/color]

          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.
          [color=blue]
          > though on some hardware you might need something else).[/color]

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

          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

          Comment

          • Patrick TJ McPhee

            #6
            Re: XML over HTTPS

            In article <1115838392.173 501.145980@g43g 2000cwa.googleg roups.com>,
            chitu <cperiyak@gmail .com> 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="Transacti on">
            % <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
            ptjm@interlog.c om

            Comment

            • Ian Wilson

              #7
              Re: XML over HTTPS

              chitu wrote:[color=blue][color=green]
              >>: I am having trouble sending XML data over HTTPS.
              >>
              >>: Clients connect to server using SSL_XXX system calls
              >>: and server is running apache.[/color][/color]
              [color=blue]
              > 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="Transacti on">
              > <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.[/color]

              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
              [color=blue]
              > If I remove them I get 404 Error.[/color]

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

              Comment

              Working...