Skip to content

Commit

Permalink
Update license information
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed Apr 2, 2019
1 parent dc797bc commit a6d76de
Show file tree
Hide file tree
Showing 49 changed files with 204 additions and 142 deletions.
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2010-2014 Pierrick Charron
Copyright (c) 2016-2018 Holger Woltersdorf & Contributors
Copyright (c) 2016-2019 Holger Woltersdorf & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand All @@ -22,4 +22,6 @@ SOFTWARE.
Contributors:

* https://github.com/dugwood (Yvan Taviaud)
* https://github.com/rbro
* https://github.com/rbro
* https://github.com/theseer (Arne Blankerts)
* https://github.com/andybee (Andy Buckingham)
21 changes: 21 additions & 0 deletions bin/exampleWorker.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

sleep( (int)($_REQUEST['sleep'] ?? 0) );

Expand Down
2 changes: 1 addition & 1 deletion bin/examples.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion bin/fcgiget
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -183,7 +183,7 @@ public function waitForResponse( int $requestId, ?int $timeoutMs = null ) : void
* @param int|null $timeoutMs
*
* @throws ReadFailedException
* @throws \Throwable
* @throws Throwable
*/
public function waitForResponses( ?int $timeoutMs = null ) : void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Constants/RequestMethod.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Constants/ServerProtocol.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
47 changes: 25 additions & 22 deletions src/Encoders/NameValuePairEncoder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand All @@ -24,6 +24,9 @@
namespace hollodotme\FastCGI\Encoders;

use hollodotme\FastCGI\Interfaces\EncodesNameValuePair;
use function chr;
use function ord;
use function strlen;

/**
* Class NameValuePairEncoder
Expand All @@ -45,34 +48,34 @@ public function encodePairs( array $pairs ) : string

public function encodePair( string $name, string $value ) : string
{
$nameLength = \strlen( $name );
$valueLength = \strlen( $value );
$nameLength = strlen( $name );
$valueLength = strlen( $value );

if ( $nameLength < 128 )
{
/* nameLengthB0 */
$nameValuePair = \chr( $nameLength );
$nameValuePair = chr( $nameLength );
}
else
{
/* nameLengthB3 & nameLengthB2 & nameLengthB1 & nameLengthB0 */
$nameValuePair = \chr( ($nameLength >> 24) | 0x80 )
. \chr( ($nameLength >> 16) & 0xFF )
. \chr( ($nameLength >> 8) & 0xFF )
. \chr( $nameLength & 0xFF );
$nameValuePair = chr( ($nameLength >> 24) | 0x80 )
. chr( ($nameLength >> 16) & 0xFF )
. chr( ($nameLength >> 8) & 0xFF )
. chr( $nameLength & 0xFF );
}
if ( $valueLength < 128 )
{
/* valueLengthB0 */
$nameValuePair .= \chr( $valueLength );
$nameValuePair .= chr( $valueLength );
}
else
{
/* valueLengthB3 & valueLengthB2 & valueLengthB1 & valueLengthB0 */
$nameValuePair .= \chr( ($valueLength >> 24) | 0x80 )
. \chr( ($valueLength >> 16) & 0xFF )
. \chr( ($valueLength >> 8) & 0xFF )
. \chr( $valueLength & 0xFF );
$nameValuePair .= chr( ($valueLength >> 24) | 0x80 )
. chr( ($valueLength >> 16) & 0xFF )
. chr( ($valueLength >> 8) & 0xFF )
. chr( $valueLength & 0xFF );
}

return $nameValuePair . $name . $value;
Expand All @@ -84,29 +87,29 @@ public function decodePairs( string $data, int $length = -1 ) : array

if ( $length === -1 )
{
$length = \strlen( $data );
$length = strlen( $data );
}

$p = 0;

while ( $p !== $length )
{
$nameLength = \ord( $data{$p++} );
$nameLength = ord( $data{$p++} );
if ( $nameLength >= 128 )
{
$nameLength &= (0x7F << 24);
$nameLength |= (\ord( $data{$p++} ) << 16);
$nameLength |= (\ord( $data{$p++} ) << 8);
$nameLength |= \ord( $data{$p++} );
$nameLength |= (ord( $data{$p++} ) << 16);
$nameLength |= (ord( $data{$p++} ) << 8);
$nameLength |= ord( $data{$p++} );
}

$valueLength = \ord( $data{$p++} );
$valueLength = ord( $data{$p++} );
if ( $valueLength >= 128 )
{
$valueLength = ($nameLength & 0x7F << 24);
$valueLength |= (\ord( $data{$p++} ) << 16);
$valueLength |= (\ord( $data{$p++} ) << 8);
$valueLength |= \ord( $data{$p++} );
$valueLength |= (ord( $data{$p++} ) << 16);
$valueLength |= (ord( $data{$p++} ) << 8);
$valueLength |= ord( $data{$p++} );
}
$array[ substr( $data, $p, $nameLength ) ] = substr( $data, $p + $nameLength, $valueLength );
$p += ($nameLength + $valueLength);
Expand Down
35 changes: 19 additions & 16 deletions src/Encoders/PacketEncoder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand All @@ -24,6 +24,9 @@
namespace hollodotme\FastCGI\Encoders;

use hollodotme\FastCGI\Interfaces\EncodesPacket;
use function chr;
use function ord;
use function strlen;

/**
* Class PacketEncoder
Expand All @@ -35,28 +38,28 @@ final class PacketEncoder implements EncodesPacket

public function encodePacket( int $type, string $content, int $requestId ) : string
{
$contentLength = \strlen( $content );
$contentLength = strlen( $content );

return \chr( self::VERSION ) /* version */
. \chr( $type ) /* type */
. \chr( ($requestId >> 8) & 0xFF ) /* requestIdB1 */
. \chr( $requestId & 0xFF ) /* requestIdB0 */
. \chr( ($contentLength >> 8) & 0xFF ) /* contentLengthB1 */
. \chr( $contentLength & 0xFF ) /* contentLengthB0 */
. \chr( 0 ) /* paddingLength */
. \chr( 0 ) /* reserved */
return chr( self::VERSION ) /* version */
. chr( $type ) /* type */
. chr( ($requestId >> 8) & 0xFF ) /* requestIdB1 */
. chr( $requestId & 0xFF ) /* requestIdB0 */
. chr( ($contentLength >> 8) & 0xFF ) /* contentLengthB1 */
. chr( $contentLength & 0xFF ) /* contentLengthB0 */
. chr( 0 ) /* paddingLength */
. chr( 0 ) /* reserved */
. $content; /* content */
}

public function decodeHeader( string $data ) : array
{
$header = [];
$header['version'] = \ord( $data{0} );
$header['type'] = \ord( $data{1} );
$header['requestId'] = (\ord( $data{2} ) << 8) + \ord( $data{3} );
$header['contentLength'] = (\ord( $data{4} ) << 8) + \ord( $data{5} );
$header['paddingLength'] = \ord( $data{6} );
$header['reserved'] = \ord( $data{7} );
$header['version'] = ord( $data{0} );
$header['type'] = ord( $data{1} );
$header['requestId'] = (ord( $data{2} ) << 8) + ord( $data{3} );
$header['contentLength'] = (ord( $data{4} ) << 8) + ord( $data{5} );
$header['paddingLength'] = ord( $data{6} );
$header['reserved'] = ord( $data{7} );

return $header;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ConnectException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
6 changes: 4 additions & 2 deletions src/Exceptions/FastCGIClientException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand All @@ -23,7 +23,9 @@

namespace hollodotme\FastCGI\Exceptions;

class FastCGIClientException extends \Exception
use Exception;

class FastCGIClientException extends Exception
{

}
2 changes: 1 addition & 1 deletion src/Exceptions/ReadFailedException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/TimedoutException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/WriteFailedException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types = 1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ConfiguresSocketConnection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/EncodesNameValuePair.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/EncodesPacket.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ProvidesRequestData.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/ProvidesResponseData.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand Down
5 changes: 3 additions & 2 deletions src/Requests/AbstractRequest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php declare(strict_types=1);
/*
* Copyright (c) 2010-2014 Pierrick Charron
* Copyright (c) 2016-2018 Holger Woltersdorf
* Copyright (c) 2016-2019 Holger Woltersdorf & Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
Expand All @@ -25,6 +25,7 @@

use hollodotme\FastCGI\Constants\ServerProtocol;
use hollodotme\FastCGI\Interfaces\ProvidesRequestData;
use function strlen;

/**
* Class AbstractRequest
Expand Down Expand Up @@ -177,7 +178,7 @@ public function getContent() : string
public function setContent( string $content ) : void
{
$this->content = $content;
$this->contentLength = \strlen( $content );
$this->contentLength = strlen( $content );
}

public function setCustomVar( string $key, $value ) : void
Expand Down
Loading

0 comments on commit a6d76de

Please sign in to comment.