Giter Site home page Giter Site logo

Comments (3)

aconital avatar aconital commented on July 18, 2024

I'm getting the same error. This is the crash:

Invalid header syntax #0 /var/www/api/vendor/guzzlehttp/psr7/src/Message.php(235): GuzzleHttp\Psr7\Message::parseMessage() #1 /var/www/api/vendor/troydavisson/phrets/src/Parsers/GetObject/Multiple.php(52): GuzzleHttp\Psr7\Message::parseResponse() #2 /var/www/api/vendor/troydavisson/phrets/src/Session.php(136): PHRETS\Parsers\GetObject\Multiple->parse() #3 /var/www/api/app/Traits/ListingSyncTrait.php(1914): PHRETS\Session->GetObject()

Here is the response from feed:

  #response: GuzzleHttp\Psr7\Response^ {#6225
    -reasonPhrase: "OK"
    -statusCode: 200
    -headers: array:10 [
      "Date" => array:1 [
        0 => "Fri, 13 Oct 2023 19:11:32 GMT"
      ]
      "Content-Type" => array:1 [
        0 => "multipart/parallel; boundary=StratusRETS-XYZZY;charset=utf-8"
      ]
      "Transfer-Encoding" => array:1 [
        0 => "chunked"
      ]
      "Connection" => array:1 [
        0 => "keep-alive"
      ]
      "Set-Cookie" => array:2 [
        0 => "AWSALB=cookie; Expires=Fri, 20 Oct 2023 19:11:32 GMT; Path=/"
        1 => "AWSALBCORS=cookie; Expires=Fri, 20 Oct 2023 19:11:32 GMT; Path=/; SameSite=None"
      ]
      "RETS-Version" => array:1 [
        0 => "RETS/1.5"
      ]
      "cache-control" => array:1 [
        0 => "private"
      ]
      "Server" => array:1 [
        0 => "StratusRETS/1.7"
      ]
      "MIME-Version" => array:1 [
        0 => "1.0"
      ]
      "x-encoded-content-encoding" => array:1 [
        0 => "gzip"
      ]
    ]
    -headerNames: array:10 [
      "date" => "Date"
      "content-type" => "Content-Type"
      "transfer-encoding" => "Transfer-Encoding"
      "connection" => "Connection"
      "set-cookie" => "Set-Cookie"
      "rets-version" => "RETS-Version"
      "cache-control" => "cache-control"
      "server" => "Server"
      "mime-version" => "MIME-Version"
      "x-encoded-content-encoding" => "x-encoded-content-encoding"
    ]
    -protocol: "1.1"
    -stream: GuzzleHttp\Psr7\Stream^ {#6227
      -stream: stream resource {@1566
        wrapper_type: "PHP"
        stream_type: "TEMP"
        mode: "w+b"
        unread_bytes: 0
        seekable: true
        uri: "php://temp"
        options: []
      }
      -size: null
      -seekable: true
      -readable: true
      -writable: true
      -uri: "php://temp"
      -customMetadata: []
    }
  }
}

And this is $response->getBody() from phrets/src/Parsers/GetObject/Multiple.php

  -stream: stream resource {@1566
    wrapper_type: "PHP"
    stream_type: "TEMP"
    mode: "w+b"
    unread_bytes: 0
    seekable: true
    uri: "php://temp"
    options: []
  }
  -size: null
  -seekable: true
  -readable: true
  -writable: true
  -uri: "php://temp"
  -customMetadata: []
}

$boundary value is StratusRETS-XYZZY

So it seems some of the $part s cannot be parsed. Here is part that parseResponse can't parse:

https://drive.google.com/file/d/1KaIEL__NPNiy4-IvnY1SgVoLF9-cF358/view?usp=sharing

And this is the full body before this library removes boundary and cleans up any preamble/epilogue:

https://drive.google.com/file/d/1KBSlejFsV7dTDMR-MLSZlCFbFahHRbRu/view?usp=sharing

@troydavisson is there anything else I can provide to assist with this?

from phrets.

aconital avatar aconital commented on July 18, 2024

Update: I think I know what's going on. When "Description:" value has line break and is in multiline like the example I provided above:

Content-Type: image/jpeg
Content-ID: C7063702
Object-ID: 10
Description: QUARTZ COUNTERS MARBLE
BACKSPLASH

The code fails to parse. I tried removing the value and it worked. I added the following code to troydavisson/phrets/src/Parsers/GetObject/Multiple.php line 39

$fieldToUpdate = 'Description';
// Create a regular expression pattern to match the field and its value
$pattern = "/{$fieldToUpdate}:(.*?)(\r?\n\r?\n|$)/si";
// Use preg_replace to remove the value until an empty line is reached
$body = preg_replace($pattern, "{$fieldToUpdate}:\r\n\r\n", $body);

I'll open a PR shortly.

from phrets.

aconital avatar aconital commented on July 18, 2024

@troydavisson The PR is up if you are okay with the change

#323

from phrets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.