-
Notifications
You must be signed in to change notification settings - Fork 159
/
hackttp.patch
46 lines (40 loc) · 1.63 KB
/
hackttp.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
diff --git a/vendor/usox/hackttp/src/Response/TemporaryFileSapiEmitter.hack b/vendor/usox/hackttp/src/Response/TemporaryFileSapiEmitter.hack
index 5eb02f6..747753a 100644
--- a/vendor/usox/hackttp/src/Response/TemporaryFileSapiEmitter.hack
+++ b/vendor/usox/hackttp/src/Response/TemporaryFileSapiEmitter.hack
@@ -34,27 +34,33 @@ final class TemporaryFileSapiEmitter implements EmitterInterface {
$body = $response->getBody();
- /* HH_FIXME[4053] */
- $path = $body->getPath();
-
- $path as File\Path;
+ // Lambda is used to force $path to be string, not TAny (`_`).
+ $path = (): string ==> {
+ /*HH_FIXME[4053] getPath is not part of the WriteHandle interface.*/
+ $path_maybe_object = $body->getPath();
+ // Path is going to be removed from the hsl.
+ // We just used `->toString()` anyway.
+ // This hacky expression is needed, because `$path_maybe_object`
+ // is of the TAny type (`_`), so the typechecker won't error when
+ // `->getPath()` starts returning a string.
+ // This expression works for both Path and string.
+ return $path_maybe_object |> $$ is string ? $$ : $$->toString();
+ }();
$this->writeStatusLine($response);
$this->writeHeaders($response);
- $temporary_file_path = $path->toString();
-
if ($body is IO\CloseableHandle) {
$body->close();
}
- $read_handle = File\open_read_only($temporary_file_path);
+ $read_handle = File\open_read_only($path);
using ($read_handle->closeWhenDisposed()) {
$out = IO\request_output();
$content = await $read_handle->readAllAsync();
await $out->writeAllAsync($content);
};
- \unlink($temporary_file_path);
+ \unlink($path);
}
/**