Bad Response after /item/bulk

  • sammlerkalle_dev

    19 berichten

    Duitsland

    Hello!

    After starting a bulk of items there is an error in the response: I get 3 PHP-Warnings on this line:
    $itemstart_data = simplexml_load_string($xml_response);

    Failures:
    - simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found

    - simplexml_load_string(): ^

    - simplexml_load_string(): HTTP/1.1 200 OK

    The Notification is ok and all items were started some minutes later. The same with only one item (using /item) is ok (response and nitification).

    I need this response, because I will start new items with a cronjob. With a positive response I can mark the item in the database as uploaded before the notification is here. So no item will start two times in the time I wait fpr the notification.
  • Rekening verwijderd
    Rekening verwijderd

    0 berichten

    België

    Hello!

    After starting a bulk of items there is an error in the response: I get 3 PHP-Warnings on this line:
    $itemstart_data = simplexml_load_string($xml_response);

    Failures:
    - simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found

    - simplexml_load_string(): ^

    - simplexml_load_string(): HTTP/1.1 200 OK

    The Notification is ok and all items were started some minutes later. The same with only one item (using /item) is ok (response and nitification).

    I need this response, because I will start new items with a cronjob. With a positive response I can mark the item in the database as uploaded before the notification is here. So no item will start two times in the time I wait fpr the notification.
    • Aangemaakt 28 apr 2012 op 14:12
    • #383860
    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
  • sammlerkalle_dev

    19 berichten

    Duitsland

    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
    • Aangemaakt 30 apr 2012 op 08:13
    • #384044
    Here is the response of Item/bulk (without simplexml_load_string()):

    HTTP/1.1 200 OK
    Date: Mon, 30 Apr 2012 15:07:08 GMT
    Server: Apache/2.2.16 (Debian)
    X-Powered-By: PHP/5.3.3-7+squeeze1
    Content-Length: 955
    Connection: close
    Content-Type: application/xml


    2f186897619de70e22a0801e786bc22f
    2012-04-30 17:07:09


    item/bulk
    POST
    200



    Your request was taken into account!
    123458


    Your request was taken into account!
    123460


    ********************************
    And here the same for (1) /item:


    56c424b4622f3897018604099119f530
    2012-04-30 17:10:11


    item
    POST
    200



    Your request was taken into account!
    123458




    ********************************
    You see, there are HTTP-Header-Informations in the returned bulk-response-data, and not in the response for a single item. So simplexml_load_string() fails, when I upload a bulk..
  • sammlerkalle_dev

    19 berichten

    Duitsland

    Here is the response of Item/bulk (without simplexml_load_string()):

    HTTP/1.1 200 OK
    Date: Mon, 30 Apr 2012 15:07:08 GMT
    Server: Apache/2.2.16 (Debian)
    X-Powered-By: PHP/5.3.3-7+squeeze1
    Content-Length: 955
    Connection: close
    Content-Type: application/xml


    2f186897619de70e22a0801e786bc22f
    2012-04-30 17:07:09


    item/bulk
    POST
    200



    Your request was taken into account!
    123458


    Your request was taken into account!
    123460


    ********************************
    And here the same for (1) /item:


    56c424b4622f3897018604099119f530
    2012-04-30 17:10:11


    item
    POST
    200



    Your request was taken into account!
    123458




    ********************************
    You see, there are HTTP-Header-Informations in the returned bulk-response-data, and not in the response for a single item. So simplexml_load_string() fails, when I upload a bulk..
    • Aangemaakt 30 apr 2012 op 11:20
    • #384070
    I hope you understand, because the forum don't show the xml. How is it possible to post code here? Only as a screenshot?
  • Rekening verwijderd
    Rekening verwijderd

    0 berichten

    België

    I hope you understand, because the forum don't show the xml. How is it possible to post code here? Only as a screenshot?
    • Aangemaakt 30 apr 2012 op 11:24
    • #384071
    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
  • sammlerkalle_dev

    19 berichten

    Duitsland

    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
    • Aangemaakt 2 mei 2012 op 04:41
    • #384348
    Done.
  • Rekening verwijderd
    Rekening verwijderd

    0 berichten

    België

    Done.
    • Aangemaakt 2 mei 2012 op 05:15
    • #384353
    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
  • sammlerkalle_dev

    19 berichten

    Duitsland

    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
    • Aangemaakt 2 mei 2012 op 08:40
    • #384401
    Hello xavier,

    I need the header, so I can't use your curl_setopt(). I've testet something and I will tell you, what I found. I've also to tell you, how I have to use curl - sorry that I didn't before.

    In the case that safe_mode is enabled or open_basedir is not empty, it is not possible to use curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true). Safe_Mode is off, but open_basedir is not empty at my server. I need this for another script on this domain, so I cannot change it. ini_set() ist not allowed for the open_basedir-value. So I use a workaround that works like this:

    I created a own function, e.g. called my_curl($handle). I call this function instead of the php-function curl_exec(). Im my function I don't set the FOLLOWLOCATION-Option, but the option curl_setopt ($handle, CURLOPT_HEADER, true). And now I call the php-function curl_exec().

    Now I split the response with list($header, $data) = explode("\r\n\r\n", $response, 2). Now I check the HTTP-Code in the $header. If it is 301 or 302 I extract (parse) the redirection-url out of this header, set the curl_option to the new url and call again (recursively) my function like this: return my_curl($handle)

    In the case that the returned HTTP-Code is not 301/302 I return $data as result of the function my-curl().

    That works fine for example with the /item-function, because there is only one double-linefeed between Header and Data. But with /item/bulk there is an interim-Header (HTTP 100) and between this Interim-Header and the real Header (HTTP 200) is one more double-linefeed.

    So the list-function above fails, because it returns the interim-Header as $header and all other parts (Header-200 and response-data) as $data.

    I think I have to check for '100 Continue' before I split $header and $data. Or do you see another way?

    Thank you.

    Best regards
  • Rekening verwijderd
    Rekening verwijderd

    0 berichten

    België

    Hello xavier,

    I need the header, so I can't use your curl_setopt(). I've testet something and I will tell you, what I found. I've also to tell you, how I have to use curl - sorry that I didn't before.

    In the case that safe_mode is enabled or open_basedir is not empty, it is not possible to use curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true). Safe_Mode is off, but open_basedir is not empty at my server. I need this for another script on this domain, so I cannot change it. ini_set() ist not allowed for the open_basedir-value. So I use a workaround that works like this:

    I created a own function, e.g. called my_curl($handle). I call this function instead of the php-function curl_exec(). Im my function I don't set the FOLLOWLOCATION-Option, but the option curl_setopt ($handle, CURLOPT_HEADER, true). And now I call the php-function curl_exec().

    Now I split the response with list($header, $data) = explode("\r\n\r\n", $response, 2). Now I check the HTTP-Code in the $header. If it is 301 or 302 I extract (parse) the redirection-url out of this header, set the curl_option to the new url and call again (recursively) my function like this: return my_curl($handle)

    In the case that the returned HTTP-Code is not 301/302 I return $data as result of the function my-curl().

    That works fine for example with the /item-function, because there is only one double-linefeed between Header and Data. But with /item/bulk there is an interim-Header (HTTP 100) and between this Interim-Header and the real Header (HTTP 200) is one more double-linefeed.

    So the list-function above fails, because it returns the interim-Header as $header and all other parts (Header-200 and response-data) as $data.

    I think I have to check for '100 Continue' before I split $header and $data. Or do you see another way?

    Thank you.

    Best regards
    • Aangemaakt 2 mei 2012 op 11:04
    • #384442
    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
  • sammlerkalle_dev

    19 berichten

    Duitsland

    De informatie is niet meer beschikbaar omdat de rekening van deze gebruiker is verwijderd (AVG)
    • Aangemaakt 3 mei 2012 op 09:34
    • #384560
    I Think preg_match_all() is better than list(). Thank you.
  • sammlerkalle_dev

    19 berichten

    Duitsland

    I Think preg_match_all() is better than list(). Thank you.
    • Aangemaakt 3 mei 2012 op 14:38
    • #384609
    Nothing new, this is only a < test > (bracket)