Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 37a73b1

Browse files
jjergususox
authored andcommitted
support HSL 4.25+
1 parent 2acc7b9 commit 37a73b1

File tree

11 files changed

+30
-24
lines changed

11 files changed

+30
-24
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
composer.lock
2-
vendor
2+
vendor
3+
*.hhast.parser-cache

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"require": {
1616
"hhvm": "^4.1",
1717
"facebook/hack-http-request-response-interfaces": "^0.2",
18-
"hhvm/hsl": "^4.1",
19-
"hhvm/hsl-experimental": "^4.1",
18+
"hhvm/hsl": "^4.25",
19+
"hhvm/hsl-experimental": "^4.25",
2020
"hhvm/type-assert": "^3.3",
2121
"usox/hack-http-factory-interfaces": "^0.2"
2222
},

src/Marshaler/UploadedFileMarshaler.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Usox\HackTTP\Marshaler;
1111

1212
use namespace Facebook\Experimental\Http\Message;
1313
use type Usox\HackTTP\UploadedFile;
14-
use namespace HH\Lib\{C, Experimental\Filesystem, Str};
14+
use namespace HH\Lib\{C, Experimental\File, Str};
1515

1616
type UploadedFileType = shape(
1717
'tmp_name' => string,
@@ -72,7 +72,7 @@ final class UploadedFileMarshaler implements UploadedFileMarshalerInterface {
7272
$error = $file['error'] === 0 ? null : Message\UploadedFileError::assert($file['error']);
7373

7474
return new UploadedFile(
75-
Filesystem\open_read_only_non_disposable($file['tmp_name']),
75+
File\open_read_only_nd($file['tmp_name']),
7676
$file['size'],
7777
$error,
7878
$file['name'] ?? '',

src/Request.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Usox\HackTTP;
1111

1212
use namespace Facebook\Experimental\Http\Message;
13-
use namespace HH\Lib\{C, Experimental\IO, Dict};
13+
use namespace HH\Lib\{C, Dict, Experimental\IO};
1414

1515
class Request implements Message\RequestInterface {
1616

src/RequestFactory.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class RequestFactory implements RequestFactoryInterface {
2222
return new Request(
2323
$method,
2424
$uri,
25-
IO\server_input(),
25+
IO\request_input(),
2626
dict[]
2727
);
2828
}

src/Response/TemporaryFileSapiEmitter.hack

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Usox\HackTTP\Response;
1111

12-
use namespace HH\Lib\{Experimental\Filesystem, Experimental\IO, Math, Str};
12+
use namespace HH\Lib\{Experimental\File, Experimental\IO, Math, Str};
1313
use type Facebook\Experimental\Http\Message\ResponseInterface;
1414
use type Usox\HackTTP\Exception\EmitterException;
1515

@@ -37,15 +37,18 @@ final class TemporaryFileSapiEmitter implements EmitterInterface {
3737
/* HH_FIXME[4053] */
3838
$path = $body->getPath();
3939

40-
$path as Filesystem\Path;
40+
$path as File\Path;
4141

4242
$this->writeStatusLine($response);
4343
$this->writeHeaders($response);
4444

4545
$temporary_file_path = $path->toString();
4646

47-
await $body->closeAsync();
48-
await using ($read_handle = Filesystem\open_read_only($temporary_file_path)) {
47+
if ($body is IO\NonDisposableHandle) {
48+
await $body->closeAsync();
49+
}
50+
51+
await using ($read_handle = File\open_read_only($temporary_file_path)) {
4952
$out = IO\request_output();
5053
$content = await $read_handle->readAsync(Math\INT64_MAX);
5154
await $out->writeAsync($content);

src/UploadedFile.hack

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Usox\HackTTP;
1111

1212
use namespace Facebook\Experimental\Http\Message;
13-
use namespace HH\Lib\{Experimental\IO, Experimental\Filesystem, Str};
13+
use namespace HH\Lib\{Experimental\File, Experimental\IO, Str};
1414

1515
final class UploadedFile implements Message\UploadedFileInterface {
1616

@@ -51,9 +51,11 @@ final class UploadedFile implements Message\UploadedFileInterface {
5151
}
5252

5353
private async function writeAsync(string $target_path): Awaitable<void> {
54-
await using $target = Filesystem\open_write_only($target_path);
54+
await using $target = File\open_write_only($target_path);
5555
await $target->writeAsync($this->stream->rawReadBlocking());
56-
await $this->stream->closeAsync();
56+
if ($this->stream is IO\NonDisposableHandle) {
57+
await $this->stream->closeAsync();
58+
}
5759
}
5860

5961
public function getSize(): ?int {

src/Uri.hack

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ final class Uri implements UriInterface {
7575

7676
if ($this->raw_query !== '') {
7777
$uri .= '?'.$this->raw_query;
78-
} elseif (C\count($this->query) > 0) {
78+
} else if (C\count($this->query) > 0) {
7979
$uri .= Str\format(
8080
'?%s',
8181
Dict\map_with_key(
@@ -387,7 +387,7 @@ final class Uri implements UriInterface {
387387
'A relative URI must not have a path beginning with a segment containing a colon',
388388
);
389389
}
390-
} elseif ($path !== '' && Str\search($path, '/') !== 0) {
390+
} else if ($path !== '' && Str\search($path, '/') !== 0) {
391391
throw new \InvalidArgumentException(
392392
'The path of a URI with an authority must start with a slash "/" or be empty',
393393
);

src/functions.hack

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Usox\HackTTP;
1111

1212
use namespace Facebook\Experimental\Http\Message;
13-
use namespace HH\Lib\{Experimental\Filesystem, Experimental\IO};
13+
use namespace HH\Lib\Experimental\{File, IO};
1414

1515
/**
1616
* We still have to rely on good old php's super globals, so provide a
@@ -59,9 +59,9 @@ function create_response(
5959
int $code = 200,
6060
string $reason = '',
6161
): Message\ResponseInterface {
62-
$write_handle = Filesystem\open_write_only_non_disposable(
62+
$write_handle = File\open_write_only_nd(
6363
\sys_get_temp_dir().'/'.\bin2hex(\random_bytes(16)),
64-
Filesystem\FileWriteMode::MUST_CREATE
64+
File\WriteMode::MUST_CREATE
6565
);
6666
return new Response($write_handle, $code, $reason);
6767
}

tests/Response/TemporaryFileSapiEmitterTest.hack

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Usox\HackTTP\Response;
1111

1212
use namespace Facebook\Experimental\Http\Message;
1313
use type Facebook\HackTest\HackTest;
14-
use namespace HH\Lib\Experimental\Filesystem;
14+
use namespace HH\Lib\Experimental\File;
1515
use function Usox\HackMock\{mock, prospect};
1616

1717
class TemporaryFileSapiEmitterTest extends HackTest {
@@ -30,8 +30,8 @@ class TemporaryFileSapiEmitterTest extends HackTest {
3030
\file_put_contents($path, $body_value);
3131

3232
$response = mock(Message\ResponseInterface::class);
33-
$handle = mock(Filesystem\FileHandle::class);
34-
$path_handle = mock(Filesystem\Path::class);
33+
$handle = mock(File\Handle::class);
34+
$path_handle = mock(File\Path::class);
3535

3636
prospect($handle, 'getPath')
3737
->once()

0 commit comments

Comments
 (0)