Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorException when parsing header in HTTP response: Undefined offset: 1 #342

Open
cweiske opened this issue Mar 4, 2024 · 0 comments
Open

Comments

@cweiske
Copy link
Contributor

cweiske commented Mar 4, 2024

Very seldom I get an ErrorException when using php-spo because one of the response header lines does not contain a : character. This happened ~8 times in the last 2 years.

I unfortunately do not have an example of such a HTTP response header.
The relevant code in Runtime/Http/Response.php is

        foreach ($lines as $line){
            if($line != ""){
                list($k, $v) = preg_split("/[ :]/", $line,2);
                $this->Headers[$k] = $v;
            }
        }

and the error message is

ErrorException: Undefined offset: 1

It would be nice if the code would check if the header line can indeed be split before doing so.

Stack trace

ErrorException: Undefined offset: 1
#27 /vendor/vgrem/php-spo/src/Runtime/Http/Response.php(30): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#26 /vendor/vgrem/php-spo/src/Runtime/Http/Response.php(30): Office365\Runtime\Http\Response::getHeaders
#25 /vendor/vgrem/php-spo/src/Runtime/Http/Response.php(44): Office365\Runtime\Http\Response::validate
#24 /vendor/vgrem/php-spo/src/Runtime/Http/Response.php(15): Office365\Runtime\Http\Response::__construct
#23 /vendor/vgrem/php-spo/src/Runtime/Http/Requests.php(30): Office365\Runtime\Http\Requests::execute
#22 /vendor/vgrem/php-spo/src/Runtime/Http/Requests.php(79): Office365\Runtime\Http\Requests::post
#21 /vendor/vgrem/php-spo/src/Runtime/Auth/SamlTokenProvider.php(105): Office365\Runtime\Auth\SamlTokenProvider::acquireAuthenticationCookies
#20 /vendor/vgrem/php-spo/src/Runtime/Auth/AuthenticationContext.php(122): Office365\Runtime\Auth\AuthenticationContext::authenticateRequest
#19 /vendor/vgrem/php-spo/src/SharePoint/ClientContext.php(244): Office365\SharePoint\ClientContext::authenticateRequest
#18 /vendor/vgrem/php-spo/src/Runtime/ClientRequest.php(168): Office365\Runtime\ClientRequest::executeQueryDirect
#17 /vendor/vgrem/php-spo/src/Runtime/OData/ODataRequest.php(142): Office365\Runtime\OData\ODataRequest::executeQueryDirect
#16 /vendor/vgrem/php-spo/src/Runtime/ClientRequest.php(149): Office365\Runtime\ClientRequest::executeQuery
#15 /vendor/vgrem/php-spo/src/Runtime/ClientRuntimeContext.php(96): Office365\Runtime\ClientRuntimeContext::executeQuery
@cweiske cweiske changed the title ErrorException when parsing HTTP response ErrorException when parsing HTTP response: Undefined offset: 1 Mar 4, 2024
@cweiske cweiske changed the title ErrorException when parsing HTTP response: Undefined offset: 1 ErrorException when parsing header in HTTP response: Undefined offset: 1 Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants