Skip to content

fread fails to return full string (but fgets works) #10

@ghost

Description

Data is php serialized string. EG 'a:6:{s:7:"success";b:1;s:5:"total";s:1:"8";s:4:"data";a:8:{i:0;a:17..." etc

Data is 7169 bytes long. Returned as "RESP Bulk String"."

$line = fread($this->getSocket(), $result + 2); // FAILS TO RETURN 7171 bytes

Ask to read 7171 but get back ony 2888 bytes. So php unserialize fails.

Verify no timeout or blocking:

017-12-17 17:10:37
'META'
array (
  'stream_type' => 'tcp_socket/ssl',
  'mode' => 'r+',
  'unread_bytes' => 0,
  'seekable' => false,
  'timed_out' => false,             OK
  'blocked' => true,                OK
  'eof' => false,
)

// This works. I get the full string (7169 bytes)
$line = fgets($this->getSocket());

So now I think this is ok provided I only use it for serialized string (never contain CRLF).

But I dunno why this is necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions