Skip to content

Commit

Permalink
Merge pull request #139 from fastly/aturon/stub-framing-headers
Browse files Browse the repository at this point in the history
Provide stubs for new framing headers settings
  • Loading branch information
aturon authored Mar 4, 2022
2 parents e411cfe + 0144adb commit 6462271
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
14 changes: 14 additions & 0 deletions lib/compute-at-edge-abi/compute-at-edge.witx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
(param $encodings $content_encodings)
(result $err (expected (error $fastly_status)))
)

;;; Adjust how this requests's framing headers are determined.
(@interface func (export "framing_headers_mode_set")
(param $h $request_handle)
(param $mode $framing_headers_mode)
(result $err (expected (error $fastly_status)))
)
)

(module $fastly_http_resp
Expand Down Expand Up @@ -404,6 +411,13 @@
(param $h $response_handle)
(result $err (expected (error $fastly_status)))
)

;;; Adjust how this response's framing headers are determined.
(@interface func (export "framing_headers_mode_set")
(param $h $response_handle)
(param $mode $framing_headers_mode)
(result $err (expected (error $fastly_status)))
)
)

(module $fastly_dictionary
Expand Down
5 changes: 5 additions & 0 deletions lib/compute-at-edge-abi/typenames.witx
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@
(typename $content_encodings
(flags (@witx repr u32)
$gzip))

(typename $framing_headers_mode
(enum (@witx tag u32)
$automatic
$manually_from_headers))
8 changes: 4 additions & 4 deletions lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ impl TryInto<FastlyConfig> for TomlFastlyConfig {
.transpose()?
.unwrap_or_default();
Ok(FastlyConfig {
name: name.unwrap_or_else(String::new),
description: description.unwrap_or_else(String::new),
authors: authors.unwrap_or_else(Vec::new),
language: language.unwrap_or_else(String::new),
name: name.unwrap_or_default(),
description: description.unwrap_or_default(),
authors: authors.unwrap_or_default(),
language: language.unwrap_or_default(),
local_server,
})
}
Expand Down
18 changes: 16 additions & 2 deletions lib/src/wiggle_abi/req_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use {
fastly_http_req::FastlyHttpReq,
headers::HttpHeaders,
types::{
BodyHandle, CacheOverrideTag, ContentEncodings, HttpVersion, MultiValueCursor,
MultiValueCursorResult, PendingRequestHandle, RequestHandle, ResponseHandle,
BodyHandle, CacheOverrideTag, ContentEncodings, FramingHeadersMode, HttpVersion,
MultiValueCursor, MultiValueCursorResult, PendingRequestHandle, RequestHandle,
ResponseHandle,
},
},
},
Expand Down Expand Up @@ -113,6 +114,19 @@ impl FastlyHttpReq for Session {
Err(Error::NotAvailable("Client TLS data"))
}

fn framing_headers_mode_set(
&mut self,
_h: RequestHandle,
mode: FramingHeadersMode,
) -> Result<(), Error> {
match mode {
FramingHeadersMode::ManuallyFromHeaders => {
Err(Error::NotAvailable("Manual framing headers"))
}
FramingHeadersMode::Automatic => Ok(()),
}
}

fn new(&mut self) -> Result<RequestHandle, Error> {
let (parts, _) = Request::new(()).into_parts();
Ok(self.insert_request_parts(parts))
Expand Down
17 changes: 15 additions & 2 deletions lib/src/wiggle_abi/resp_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use {
fastly_http_resp::FastlyHttpResp,
headers::HttpHeaders,
types::{
BodyHandle, HttpStatus, HttpVersion, MultiValueCursor, MultiValueCursorResult,
ResponseHandle,
BodyHandle, FramingHeadersMode, HttpStatus, HttpVersion, MultiValueCursor,
MultiValueCursorResult, ResponseHandle,
},
},
},
Expand Down Expand Up @@ -166,6 +166,19 @@ impl FastlyHttpResp for Session {
Ok(())
}

fn framing_headers_mode_set(
&mut self,
_h: ResponseHandle,
mode: FramingHeadersMode,
) -> Result<(), Error> {
match mode {
FramingHeadersMode::ManuallyFromHeaders => {
Err(Error::NotAvailable("Manual framing headers"))
}
FramingHeadersMode::Automatic => Ok(()),
}
}

fn close(&mut self, resp_handle: ResponseHandle) -> Result<(), Error> {
// We don't do anything with the parts, but we do pass the error up if
// the handle given doesn't exist
Expand Down

0 comments on commit 6462271

Please sign in to comment.