Skip to content

Commit 58c9430

Browse files
authored
fix HTTP example (#83)
Also, re-bundle `bundled` directory if any of its files change. Fixes #82 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 65277a5 commit 58c9430

11 files changed

Lines changed: 23 additions & 21 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "componentize-py"
3-
version = "0.13.2"
3+
version = "0.13.3"
44
edition = "2021"
55
exclude = ["cpython"]
66

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ fn include(path: &Path) -> bool {
249249
}
250250

251251
fn add(builder: &mut Builder<impl Write>, root: &Path, path: &Path) -> Result<()> {
252+
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
253+
252254
if path.is_dir() {
253255
for entry in fs::read_dir(path)? {
254256
add(builder, root, &entry?.path())?;

bundled/poll_loop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from proxy.types import Ok, Err
1515
from proxy.imports import types, streams, poll, outgoing_handler
1616
from proxy.imports.types import IncomingBody, OutgoingBody, OutgoingRequest, IncomingResponse
17-
from proxy.imports.streams import StreamErrorClosed, InputStream
17+
from proxy.imports.streams import StreamError_Closed, InputStream
1818
from proxy.imports.poll import Pollable
1919
from typing import Optional, cast
2020

@@ -61,7 +61,7 @@ async def next(self) -> Optional[bytes]:
6161
else:
6262
return buffer
6363
except Err as e:
64-
if isinstance(e.value, StreamErrorClosed):
64+
if isinstance(e.value, StreamError_Closed):
6565
if self.stream is not None:
6666
self.stream.__exit__()
6767
self.stream = None

examples/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ run a Python-based component targetting the [wasi-cli] `command` world.
1010
## Prerequisites
1111

1212
* `Wasmtime` 18.0.0 or later
13-
* `componentize-py` 0.13.2
13+
* `componentize-py` 0.13.3
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
1717
https://github.com/bytecodealliance/wasmtime/releases/tag/v18.0.0.
1818

1919
```
2020
cargo install --version 18.0.0 wasmtime-cli
21-
pip install componentize-py==0.13.2
21+
pip install componentize-py==0.13.3
2222
```
2323

2424
## Running the demo

examples/http/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ run a Python-based component targetting the [wasi-http] `proxy` world.
1010
## Prerequisites
1111

1212
* `Wasmtime` 18.0.0 or later
13-
* `componentize-py` 0.13.2
13+
* `componentize-py` 0.13.3
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
1717
https://github.com/bytecodealliance/wasmtime/releases/tag/v18.0.0.
1818

1919
```
2020
cargo install --version 18.0.0 wasmtime-cli
21-
pip install componentize-py==0.13.2
21+
pip install componentize-py==0.13.3
2222
```
2323

2424
## Running the demo

examples/http/app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from proxy.types import Ok
1414
from proxy.imports import types
1515
from proxy.imports.types import (
16-
MethodGet, MethodPost, Scheme, SchemeHttp, SchemeHttps, SchemeOther, IncomingRequest, ResponseOutparam,
16+
Method_Get, Method_Post, Scheme, Scheme_Http, Scheme_Https, Scheme_Other, IncomingRequest, ResponseOutparam,
1717
OutgoingResponse, Fields, OutgoingBody, OutgoingRequest
1818
)
1919
from poll_loop import Stream, Sink, PollLoop
@@ -40,7 +40,7 @@ async def handle_async(request: IncomingRequest, response_out: ResponseOutparam)
4040
path = request.path_with_query()
4141
headers = request.headers().entries()
4242

43-
if isinstance(method, MethodGet) and path == "/hash-all":
43+
if isinstance(method, Method_Get) and path == "/hash-all":
4444
# Collect one or more "url" headers, download their contents
4545
# concurrently, compute their SHA-256 hashes incrementally (i.e. without
4646
# buffering the response bodies), and stream the results back to the
@@ -61,7 +61,7 @@ async def handle_async(request: IncomingRequest, response_out: ResponseOutparam)
6161

6262
sink.close()
6363

64-
elif isinstance(method, MethodPost) and path == "/echo":
64+
elif isinstance(method, Method_Post) and path == "/echo":
6565
# Echo the request body back to the client without buffering.
6666

6767
response = OutgoingResponse(Fields.from_list(list(filter(lambda pair: pair[0] == "content-type", headers))))
@@ -99,11 +99,11 @@ async def sha256(url: str) -> Tuple[str, str]:
9999

100100
match url_parsed.scheme:
101101
case "http":
102-
scheme: Scheme = SchemeHttp()
102+
scheme: Scheme = Scheme_Http()
103103
case "https":
104-
scheme = SchemeHttps()
104+
scheme = Scheme_Https()
105105
case _:
106-
scheme = SchemeOther(url_parsed.scheme)
106+
scheme = Scheme_Other(url_parsed.scheme)
107107

108108
request = OutgoingRequest(Fields.from_list([]))
109109
request.set_scheme(scheme)

examples/matrix-math/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ within a guest component.
1111
## Prerequisites
1212

1313
* `wasmtime` 18.0.0 or later
14-
* `componentize-py` 0.13.2
14+
* `componentize-py` 0.13.3
1515
* `NumPy`, built for WASI
1616

1717
Note that we use an unofficial build of NumPy since the upstream project does
@@ -23,7 +23,7 @@ https://github.com/bytecodealliance/wasmtime/releases/tag/v18.0.0.
2323

2424
```
2525
cargo install --version 18.0.0 wasmtime-cli
26-
pip install componentize-py==0.13.2
26+
pip install componentize-py==0.13.3
2727
curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.1/numpy-wasi.tar.gz
2828
tar xf numpy-wasi.tar.gz
2929
```

examples/sandbox/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ sandboxed Python code snippets from within a Python app.
88
## Prerequisites
99

1010
* `wasmtime-py` 18.0.0 or later
11-
* `componentize-py` 0.13.2
11+
* `componentize-py` 0.13.3
1212

1313
```
14-
pip install componentize-py==0.13.2 wasmtime==18.0.2
14+
pip install componentize-py==0.13.3 wasmtime==18.0.2
1515
```
1616

1717
## Running the demo

examples/tcp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ making an outbound TCP request using `wasi-sockets`.
1111
## Prerequisites
1212

1313
* `Wasmtime` 18.0.0 or later
14-
* `componentize-py` 0.13.2
14+
* `componentize-py` 0.13.3
1515

1616
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1717
you don't have `cargo`, you can download and install from
1818
https://github.com/bytecodealliance/wasmtime/releases/tag/v18.0.0.
1919

2020
```
2121
cargo install --version 18.0.0 wasmtime-cli
22-
pip install componentize-py==0.13.2
22+
pip install componentize-py==0.13.3
2323
```
2424

2525
## Running the demo

0 commit comments

Comments
 (0)