PHP/pear http put method and text/xml?

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

    #1

    PHP/pear http put method and text/xml?

    Hi,

    I have a problem with the HTTP implementation of the PEAR package:
    I try to PUT an XML instance to an XML database (eXist), but it always
    puts a binary:

    <?php
    require_once "HTTP/Request.php";

    $URL = 'http://ap34.ifi.inform atik.uni-goettingen.de:8 081/exist/servlet/db/may/hamlet.xml';

    $req =& new HTTP_Request("" );
    $req->setBasicAuth($ user, $passwd);
    $req->setURL($URL) ;
    $req->setMethod("PUT ");
    $req->addHeader("Con tent-Type", "text/xml");
    $req->addFile("hamle t.xml","/home/may/public_html/PHP/hamlet.xml", "text/xml");

    $response = $req->sendRequest( );
    ?>

    When looking into the database, there is also not the XML file, but
    there is a complete HTTP request:

    ***
    --HTTP_Request_f4 2cc34621bc820ec d46b8f6ef61eb7e
    Content-Disposition: form-data; name="hamlet.xm l"; filename="hamle t.xml"
    Content-Type: text/xml

    <?xml version="1.0"?>
    <!DOCTYPE PLAY SYSTEM "play.dtd">

    <PLAY>
    <TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
    etc.
    ****

    It seems not ot be a problem of the database, since it works well when doing
    the same with python (a sample that is included into the documentation of eXist),
    i.e., tha database work correctly when it receives a correct PUT.
    Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

    THX,
    Wolfgang
  • Manuel Lemos

    #2
    Re: PHP/pear http put method and text/xml?

    Hello,

    On 10/25/2004 02:29 PM, Wolfgang May wrote:[color=blue]
    > It seems not ot be a problem of the database, since it works well when doing
    > the same with python (a sample that is included into the documentation of eXist),
    > i.e., tha database work correctly when it receives a correct PUT.
    > Can anybody give me an example how HTTP PUT is applied correctly with PEAR?[/color]

    That is the way to send files with POST. PUT is different.

    I do not use PEAR classes, so I can't tell you if it can do what you
    want. I use this other HTTP client class that lets you send HTTP
    requests with arbitrary bodies:

    http://www.phpclasses.org/httpclient

    --

    Regards,
    Manuel Lemos

    PHP Classes - Free ready to use OOP components written in PHP
    http://www.phpclasses.org/

    PHP Reviews - Reviews of PHP books and other products
    http://www.phpclasses.org/reviews/

    Metastorage - Data object relational mapping layer generator

    Comment

    • Wolfgang May

      #3
      Re: PHP/pear http put method and text/xml?

      Manuel Lemos <mlemos@acm.org > wrote:[color=blue]
      > Hello,
      >
      > On 10/25/2004 02:29 PM, Wolfgang May wrote:[color=green]
      >> It seems not ot be a problem of the database, since it works well when doing
      >> the same with python (a sample that is included into the documentation of eXist),
      >> i.e., tha database work correctly when it receives a correct PUT.
      >> Can anybody give me an example how HTTP PUT is applied correctly with PEAR?[/color]
      >
      > That is the way to send files with POST. PUT is different.[/color]

      I think so ...
      [color=blue]
      > I do not use PEAR classes, so I can't tell you if it can do what you
      > want. I use this other HTTP client class that lets you send HTTP
      > requests with arbitrary bodies:
      >
      > http://www.phpclasses.org/httpclient[/color]

      The site seems to be inaccessible, and as far as I understand from
      http://scripts.incutio.com/httpclient/index.php (which also contains a description
      of this class), this supports only get/post.

      Wolfgang

      Comment

      • Manuel Lemos

        #4
        Re: PHP/pear http put method and text/xml?

        Hello,

        On 10/25/2004 04:47 PM, Wolfgang May wrote:[color=blue][color=green][color=darkred]
        >>>It seems not ot be a problem of the database, since it works well when doing
        >>>the same with python (a sample that is included into the documentation of eXist),
        >>>i.e., tha database work correctly when it receives a correct PUT.
        >>>Can anybody give me an example how HTTP PUT is applied correctly with PEAR?[/color]
        >>
        >>That is the way to send files with POST. PUT is different.[/color]
        >
        >
        > I think so ...[/color]

        PUT is much simpler because you just add the file to the request body.

        [color=blue][color=green]
        >>I do not use PEAR classes, so I can't tell you if it can do what you
        >>want. I use this other HTTP client class that lets you send HTTP
        >>requests with arbitrary bodies:
        >>
        >>http://www.phpclasses.org/httpclient[/color]
        >
        >
        > The site seems to be inaccessible, and as far as I understand from[/color]

        It was just a temporary stop. It is accessible now.

        [color=blue]
        > http://scripts.incutio.com/httpclient/index.php (which also contains a description
        > of this class), this supports only get/post.[/color]

        No, you just set the RequestMethod argument to PUT and pass file data to
        the the Body request argument. Take a look at the test_http_soap. php
        example for a demonstration.

        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/

        PHP Reviews - Reviews of PHP books and other products
        http://www.phpclasses.org/reviews/

        Metastorage - Data object relational mapping layer generator

        Comment

        • Wolfgang May

          #5
          Re: PHP/pear http put method and text/xml?

          Manuel Lemos <mlemos@acm.org > wrote:[color=blue]
          > Hello,
          >
          > On 10/25/2004 04:47 PM, Wolfgang May wrote:[color=green][color=darkred]
          >>>>It seems not ot be a problem of the database, since it works well when doing
          >>>>the same with python (a sample that is included into the documentation of eXist),
          >>>>i.e., tha database work correctly when it receives a correct PUT.
          >>>>Can anybody give me an example how HTTP PUT is applied correctly with PEAR?
          >>>
          >>>That is the way to send files with POST. PUT is different.[/color]
          >>
          >>
          >> I think so ...[/color]
          >
          > PUT is much simpler because you just add the file to the request body.[/color]

          .... but not easy enough for me.
          (anyway, I also did not find out how to do authorization with this package).
          Sometimes a documentation would be useful (and this was one of the reasons why I tried
          first to use the PEAR classes).
          [color=blue][color=green]
          >> http://scripts.incutio.com/httpclient/index.php (which also contains a description
          >> of this class), this supports only get/post.[/color][/color]

          .... it seems to be another PHP class, also called httpclient.
          [color=blue]
          > No, you just set the RequestMethod argument to PUT and pass file data to
          > the the Body request argument. Take a look at the test_http_soap. php
          > example for a demonstration.[/color]

          I wanted to use these things in a course, but the results up to now
          showed me that PHP seems not to be the right thing for this. Too many
          similar, but different classes for the same things, with too less
          documentation.

          Wolfgang

          Comment

          • Manuel Lemos

            #6
            Re: PHP/pear http put method and text/xml?

            Hello,

            On 10/28/2004 06:57 AM, Wolfgang May wrote:[color=blue][color=green][color=darkred]
            >>>>>It seems not ot be a problem of the database, since it works well when doing
            >>>>>the same with python (a sample that is included into the documentation of eXist),
            >>>>>i.e., tha database work correctly when it receives a correct PUT.
            >>>>>Can anybody give me an example how HTTP PUT is applied correctly with PEAR?
            >>>>
            >>>>That is the way to send files with POST. PUT is different.
            >>>
            >>>
            >>>I think so ...[/color]
            >>
            >>PUT is much simpler because you just add the file to the request body.[/color]
            >
            >
            > ... but not easy enough for me.
            > (anyway, I also did not find out how to do authorization with this package).[/color]

            You just have to specify the URL like you do with a browser:

            http://user:password@www.domain.com/uri/etc/

            [color=blue]
            > Sometimes a documentation would be useful (and this was one of the reasons why I tried
            > first to use the PEAR classes).[/color]

            Right, but sometimes developers do not find enough time to produce
            proper documentation. Many PEAR packages do not have proper documentation.

            At least with this class you have many examples with comments in English
            from which you can learn.

            [color=blue][color=green]
            >>No, you just set the RequestMethod argument to PUT and pass file data to
            >>the the Body request argument. Take a look at the test_http_soap. php
            >>example for a demonstration.[/color]
            >
            >
            > I wanted to use these things in a course, but the results up to now
            > showed me that PHP seems not to be the right thing for this. Too many
            > similar, but different classes for the same things, with too less
            > documentation.[/color]

            I don't think that as to do with PHP but rather with the fact that it
            takes a lot of time to produce documentation. Since this is free
            software it is hard to justify the time that it takes. Some developers
            try to do it sooner rather than later, but that is not a specific
            problem of PHP.

            --

            Regards,
            Manuel Lemos

            PHP Classes - Free ready to use OOP components written in PHP
            http://www.phpclasses.org/

            PHP Reviews - Reviews of PHP books and other products
            http://www.phpclasses.org/reviews/

            Metastorage - Data object relational mapping layer generator

            Comment

            • Wolfgang May

              #7
              Re: PHP/pear http put method and text/xml?

              Manuel Lemos <mlemos@acm.org > wrote:
              [color=blue][color=green]
              >> (anyway, I also did not find out how to do authorization with this package).[/color]
              >
              > You just have to specify the URL like you do with a browser:
              >
              > http://user:password@www.domain.com/uri/etc/[/color]

              This is not understood by the server (same for GET, but for the PEAR classes,
              setBasicAuth works fine). Although, I then experimented without access restrictions ...
              [color=blue][color=green][color=darkred]
              >>>No, you just set the RequestMethod argument to PUT and pass file data to
              >>>the the Body request argument. Take a look at the test_http_soap. php
              >>>example for a demonstration.[/color][/color][/color]

              require("http.p hp");

              set_time_limit( 0);
              $http=new http_class;
              $url="...";
              $http->GetRequestArgu ments($url,$arg uments);
              $arguments["RequestMet hod"]="PUT";
              $arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
              $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
              + and the remaining part of the soap test


              .... and it answers:

              ***
              Response body:

              HTTP/1.1 200 OK
              Date: Mon, 01 Nov 2004 16:53:28 GMT
              Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
              Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
              Content-Type: text/xml; charset=UTF-8
              Transfer-Encoding: chunked

              2b
              Document bla.xml stored as binary resource.
              0
              ***

              and puts the document as a *binary*.

              It's not a problem of the server, since HTTP PUT with python works.
              Can you tell me what I am still doing wrong?

              Wolfgang

              Comment

              • Manuel Lemos

                #8
                Re: PHP/pear http put method and text/xml?

                Hello,

                On 11/01/2004 02:58 PM, Wolfgang May wrote:[color=blue][color=green][color=darkred]
                >>>(anyway, I also did not find out how to do authorization with this package).[/color]
                >>
                >>You just have to specify the URL like you do with a browser:
                >>
                >>http://user:password@www.domain.com/uri/etc/[/color]
                >
                >
                > This is not understood by the server (same for GET, but for the PEAR classes,
                > setBasicAuth works fine). Although, I then experimented without access restrictions ...[/color]

                I was not talking about PEAR classes. As I said I do not use them.

                You can use such type of URL with the HTTP client class that I mentioned.

                [color=blue][color=green][color=darkred]
                >>>>No, you just set the RequestMethod argument to PUT and pass file data to
                >>>>the the Body request argument. Take a look at the test_http_soap. php
                >>>>example for a demonstration.[/color][/color]
                >
                >
                > require("http.p hp");
                >
                > set_time_limit( 0);
                > $http=new http_class;
                > $url="...";
                > $http->GetRequestArgu ments($url,$arg uments);
                > $arguments["RequestMet hod"]="PUT";
                > $arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
                > $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
                > + and the remaining part of the soap test
                >
                >
                > ... and it answers:
                >
                > ***
                > Response body:
                >
                > HTTP/1.1 200 OK
                > Date: Mon, 01 Nov 2004 16:53:28 GMT
                > Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
                > Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
                > Content-Type: text/xml; charset=UTF-8
                > Transfer-Encoding: chunked
                >
                > 2b
                > Document bla.xml stored as binary resource.
                > 0
                > ***
                >
                > and puts the document as a *binary*.
                >
                > It's not a problem of the server, since HTTP PUT with python works.
                > Can you tell me what I am still doing wrong?[/color]

                Nothing. Isn't that the expected response?


                --

                Regards,
                Manuel Lemos

                PHP Classes - Free ready to use OOP components written in PHP
                http://www.phpclasses.org/

                PHP Reviews - Reviews of PHP books and other products
                http://www.phpclasses.org/reviews/

                Metastorage - Data object relational mapping layer generator

                Comment

                • Wolfgang May

                  #9
                  Re: PHP/pear http put method and text/xml?

                  Manuel Lemos <mlemos@acm.org > wrote:[color=blue]
                  > Hello,
                  >
                  > On 11/01/2004 02:58 PM, Wolfgang May wrote:[color=green][color=darkred]
                  >>>>(anyway, I also did not find out how to do authorization with this package).
                  >>>
                  >>>You just have to specify the URL like you do with a browser:
                  >>>
                  >>>http://user:password@www.domain.com/uri/etc/[/color]
                  >>
                  >>
                  >> This is not understood by the server (same for GET, but for the PEAR classes,
                  >> setBasicAuth works fine). Although, I then experimented without access restrictions ...[/color]
                  >
                  > I was not talking about PEAR classes. As I said I do not use them.[/color]
                  [color=blue]
                  > You can use such type of URL with the HTTP client class that I mentioned.[/color]

                  No, as I said, the server does not understand them.
                  But, it understands authenthificati on via the setBasicAuth() method as provided by
                  e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
                  from the documentation- not support this.
                  [color=blue][color=green]
                  >> $url="...";
                  >> $http->GetRequestArgu ments($url,$arg uments);
                  >> $arguments["RequestMet hod"]="PUT";
                  >> $arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
                  >> $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
                  >> + and the remaining part of the soap test
                  >>
                  >>
                  >> ... and it answers:
                  >>
                  >> ***
                  >> Response body:
                  >>
                  >> HTTP/1.1 200 OK
                  >> Date: Mon, 01 Nov 2004 16:53:28 GMT
                  >> Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
                  >> Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
                  >> Content-Type: text/xml; charset=UTF-8
                  >> Transfer-Encoding: chunked
                  >>
                  >> 2b
                  >> Document bla.xml stored as binary resource.
                  >> 0
                  >> ***
                  >>
                  >> and puts the document as a *binary*.
                  >>
                  >> It's not a problem of the server, since HTTP PUT with python works.
                  >> Can you tell me what I am still doing wrong?[/color]
                  >
                  > Nothing. Isn't that the expected response?[/color]

                  No, with specifying "ContentType='t ext/xml'" I would expect that it
                  puts it as XML, not as a binary. When putting it as a binary, the XML
                  database system does not recognize it. The same thing works
                  well, when doing HTTP PUT by python or Java, so the problem is not due
                  to the receiving system.

                  Wolfgang

                  Comment

                  • Manuel Lemos

                    #10
                    Re: PHP/pear http put method and text/xml?

                    Hello,

                    On 11/04/2004 06:45 AM, Wolfgang May wrote:[color=blue][color=green][color=darkred]
                    >>>>>(anyway, I also did not find out how to do authorization with this package).
                    >>>>
                    >>>>You just have to specify the URL like you do with a browser:
                    >>>>
                    >>>>http://user:password@www.domain.com/uri/etc/
                    >>>
                    >>>
                    >>>This is not understood by the server (same for GET, but for the PEAR classes,
                    >>>setBasicAu th works fine). Although, I then experimented without access restrictions ...[/color]
                    >>
                    >>I was not talking about PEAR classes. As I said I do not use them.[/color]
                    >
                    >
                    >[color=green]
                    >>You can use such type of URL with the HTTP client class that I mentioned.[/color]
                    >
                    >
                    > No, as I said, the server does not understand them.
                    > But, it understands authenthificati on via the setBasicAuth() method as provided by
                    > e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
                    > from the documentation- not support this.[/color]

                    I think you are confused. The class from
                    http://www.phpclasses.org/httpclient does support that when you call
                    GetRequestArgum ents function and it does not come with documentation.
                    Are you sure you are seeing the same class?

                    [color=blue][color=green][color=darkred]
                    >>> $url="...";
                    >>> $http->GetRequestArgu ments($url,$arg uments);
                    >>> $arguments["RequestMet hod"]="PUT";
                    >>> $arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
                    >>> $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
                    >>> + and the remaining part of the soap test
                    >>>
                    >>>
                    >>>... and it answers:
                    >>>
                    >>>***
                    >>> Response body:
                    >>>
                    >>>HTTP/1.1 200 OK
                    >>>Date: Mon, 01 Nov 2004 16:53:28 GMT
                    >>>Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
                    >>>Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
                    >>>Content-Type: text/xml; charset=UTF-8
                    >>>Transfer-Encoding: chunked
                    >>>
                    >>>2b
                    >>>Document bla.xml stored as binary resource.
                    >>>0
                    >>>***
                    >>>
                    >>>and puts the document as a *binary*.
                    >>>
                    >>>It's not a problem of the server, since HTTP PUT with python works.
                    >>>Can you tell me what I am still doing wrong?[/color]
                    >>
                    >>Nothing. Isn't that the expected response?[/color]
                    >
                    >
                    > No, with specifying "ContentType='t ext/xml'" I would expect that it
                    > puts it as XML, not as a binary. When putting it as a binary, the XML
                    > database system does not recognize it. The same thing works
                    > well, when doing HTTP PUT by python or Java, so the problem is not due
                    > to the receiving system.[/color]

                    And what message appears when you do HTTP PUT with Python or Java?

                    Another thing that is odd is the httpclient class handles chunked
                    transfer encoding correctly, so you should not see those hexadecimal
                    charcters (2b 0) in the response. Are you sure that is the same
                    response that is returned when you use the httpclient class or that is
                    the response when using the PEAR class?


                    --

                    Regards,
                    Manuel Lemos

                    PHP Classes - Free ready to use OOP components written in PHP
                    http://www.phpclasses.org/

                    PHP Reviews - Reviews of PHP books and other products
                    http://www.phpclasses.org/reviews/

                    Metastorage - Data object relational mapping layer generator

                    Comment

                    • John Dunlop

                      #11
                      Re: PHP/pear http put method and text/xml?

                      Wolfgang May wrote:

                      [Unattributed source wrote:]
                      [color=blue][color=green][color=darkred]
                      > > > > http://user:password@www.domain.com/uri/etc/[/color][/color][/color]

                      That's not an HTTP URI.
                      [color=blue]
                      > No, as I said, the server does not understand them.[/color]

                      It's no less of a server for not honouring them.

                      Roll on the weekend!

                      --
                      Jock

                      Comment

                      • Wolfgang May

                        #12
                        Re: PHP/pear http put method and text/xml?

                        Manuel Lemos <mlemos@acm.org > wrote:
                        [color=blue][color=green]
                        >> No, as I said, the server does not understand them.
                        >> But, it understands authenthificati on via the setBasicAuth() method as provided by
                        >> e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
                        >> from the documentation- not support this.[/color]
                        >
                        > I think you are confused. The class from
                        > http://www.phpclasses.org/httpclient does support that when you call
                        > GetRequestArgum ents function and it does not come with documentation.
                        > Are you sure you are seeing the same class?[/color]

                        Yes. As you insisted in a previous posting that the examples serve as documentation,
                        I tacitly adopted this terminology.
                        [color=blue][color=green][color=darkred]
                        >>>>***
                        >>>> Response body:
                        >>>>
                        >>>>HTTP/1.1 200 OK
                        >>>>Date: Mon, 01 Nov 2004 16:53:28 GMT
                        >>>>Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
                        >>>>Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
                        >>>>Content-Type: text/xml; charset=UTF-8
                        >>>>Transfer-Encoding: chunked
                        >>>>
                        >>>>2b
                        >>>>Document bla.xml stored as binary resource.
                        >>>>0
                        >>>>***
                        >>>>
                        >>>>and puts the document as a *binary*.
                        >>>>
                        >>>>It's not a problem of the server, since HTTP PUT with python works.
                        >>>>Can you tell me what I am still doing wrong?
                        >>>
                        >>>Nothing. Isn't that the expected response?[/color]
                        >>
                        >>
                        >> No, with specifying "ContentType='t ext/xml'" I would expect that it
                        >> puts it as XML, not as a binary. When putting it as a binary, the XML
                        >> database system does not recognize it. The same thing works
                        >> well, when doing HTTP PUT by python or Java, so the problem is not due
                        >> to the receiving system.[/color]
                        >
                        > And what message appears when you do HTTP PUT with Python or Java?[/color]

                        reading file hamlet.xml ...
                        hamlet.xml
                        storing document to collection /db/may ...
                        Ok.

                        and then it is accessible in the database.
                        [color=blue]
                        > Another thing that is odd is the httpclient class handles chunked
                        > transfer encoding correctly, so you should not see those hexadecimal
                        > charcters (2b 0) in the response. Are you sure that is the same
                        > response that is returned when you use the httpclient class or that is
                        > the response when using the PEAR class?[/color]

                        It was the response when I used the httpclient class (created by the output
                        routines from your test_http_soap example).

                        In the meantime, a small part of the problem is solved:
                        we found out that the server ignores the content type
                        declaration when it is not exactly "text/xml" (but extended with parameters).

                        But, after fixing this, I am still back with the original question: how
                        to do PUT with HTTP with any PHP class. Writing the XML in the body (as in your
                        SOAP example) as

                        $http=new http_class;
                        $url="http://ap34.ifi.inform atik.uni-goettingen.de:8 081/exist/servlet/db/may/bla.xml";
                        $http->GetRequestArgu ments($url,$arg uments);
                        $arguments["RequestMet hod"]="PUT";
                        $arguments["Headers"]["Content-Type"]="text/xml";
                        $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";

                        does not work:

                        http/1.1 400 parsing+excepti on%3a+premature +end+of+file%2e :

                        Even if I add an explicit attribute for the content length,
                        $arguments["Headers"]["Content-length"]=54;
                        (or instead of 54 any number like 3 or 1000), it waits for some time and returns

                        http/1.1 500 read+timed+out:

                        Wolfgang


                        Comment

                        • Manuel Lemos

                          #13
                          Re: PHP/pear http put method and text/xml?

                          Hello,

                          On 11/08/2004 03:45 PM, Wolfgang May wrote:[color=blue][color=green][color=darkred]
                          >>>No, as I said, the server does not understand them.
                          >>>But, it understands authenthificati on via the setBasicAuth() method as provided by
                          >>>e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
                          >>>from the documentation- not support this.[/color]
                          >>
                          >>I think you are confused. The class from
                          >>http://www.phpclasses.org/httpclient does support that when you call
                          >>GetRequestArg uments function and it does not come with documentation.
                          >>Are you sure you are seeing the same class?[/color]
                          >
                          >
                          > Yes. As you insisted in a previous posting that the examples serve as documentation,
                          > I tacitly adopted this terminology.[/color]

                          I did not say that examples serve as documentation, but you can learn
                          from the examples because they are commented step by step like in a
                          tutorial.

                          In this case, the main example comes with an explanation on how to set
                          the user and password for authentication by setting the URL passed to
                          the GetRequestArgum ents function. I suppose you were not looking at the
                          main example.


                          [color=blue]
                          > But, after fixing this, I am still back with the original question: how
                          > to do PUT with HTTP with any PHP class. Writing the XML in the body (as in your
                          > SOAP example) as
                          >
                          > $http=new http_class;
                          > $url="http://ap34.ifi.inform atik.uni-goettingen.de:8 081/exist/servlet/db/may/bla.xml";
                          > $http->GetRequestArgu ments($url,$arg uments);
                          > $arguments["RequestMet hod"]="PUT";
                          > $arguments["Headers"]["Content-Type"]="text/xml";
                          > $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
                          >
                          > does not work:
                          >
                          > http/1.1 400 parsing+excepti on%3a+premature +end+of+file%2e :
                          >
                          > Even if I add an explicit attribute for the content length,
                          > $arguments["Headers"]["Content-length"]=54;
                          > (or instead of 54 any number like 3 or 1000), it waits for some time and returns
                          >
                          > http/1.1 500 read+timed+out:[/color]

                          The content-length header is not necessary but if you put the server
                          will wait exactly for that amount of data.

                          Anyway, there was indeed a bug in the class that was sending custom
                          request body data for HTTP POST methods. That is why the server was
                          waiting for the data until it timed out.

                          I have just fixed it and it worked with the URLs you supplied. You may
                          download the updated version now from the site. Thank you for reporting
                          the problem.

                          http://www.phpclasses.org/httpclient


                          --

                          Regards,
                          Manuel Lemos

                          PHP Classes - Free ready to use OOP components written in PHP
                          http://www.phpclasses.org/

                          PHP Reviews - Reviews of PHP books and other products
                          http://www.phpclasses.org/reviews/

                          Metastorage - Data object relational mapping layer generator

                          Comment

                          • Wolfgang May

                            #14
                            Re: PHP/pear http put method and text/xml?

                            Manuel Lemos <mlemos@acm.org > wrote:
                            [color=blue][color=green]
                            >> But, after fixing this, I am still back with the original question: how
                            >> to do PUT with HTTP with any PHP class. Writing the XML in the body (as in your
                            >> SOAP example) as
                            >>
                            >> $http=new http_class;
                            >> $url="http://ap34.ifi.inform atik.uni-goettingen.de:8 081/exist/servlet/db/may/bla.xml";
                            >> $http->GetRequestArgu ments($url,$arg uments);
                            >> $arguments["RequestMet hod"]="PUT";
                            >> $arguments["Headers"]["Content-Type"]="text/xml";
                            >> $arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
                            >>
                            >> does not work:
                            >>
                            >> http/1.1 400 parsing+excepti on%3a+premature +end+of+file%2e :
                            >>
                            >> Even if I add an explicit attribute for the content length,
                            >> $arguments["Headers"]["Content-length"]=54;
                            >> (or instead of 54 any number like 3 or 1000), it waits for some time and returns
                            >>
                            >> http/1.1 500 read+timed+out:[/color]
                            >
                            > The content-length header is not necessary but if you put the server
                            > will wait exactly for that amount of data.
                            >
                            > Anyway, there was indeed a bug in the class that was sending custom
                            > request body data for HTTP POST methods. That is why the server was
                            > waiting for the data until it timed out.
                            >
                            > I have just fixed it and it worked with the URLs you supplied. You may
                            > download the updated version now from the site. Thank you for reporting
                            > the problem.
                            >
                            > http://www.phpclasses.org/httpclient[/color]

                            THX.
                            It works now.

                            Wolfgang

                            Comment

                            Working...