Skip to content

Commit 37dc307

Browse files
seanmonstardavepachecoahl
authored
upgrade to hyper v1 (#1028)
Co-authored-by: David Pacheco <dap@oxidecomputer.com> Co-authored-by: Adam H. Leventhal <ahl@oxide.computer>
1 parent db7b377 commit 37dc307

39 files changed

+661
-346
lines changed

CHANGELOG.adoc

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515

1616
https://github.com/oxidecomputer/dropshot/compare/v0.11.0\...HEAD[Full list of commits]
1717

18+
=== Breaking Changes
19+
20+
* https://github.com/oxidecomputer/dropshot/pull/1028[#1028] Updates Dropshot for `hyper` 1.0 and `http` 1.0. Since consumers provide Dropshot with values from `hyper` and `http`, you'll need to update to `hyper` 1.0 and `http` 1.0 (or newer compatible versions), too.
21+
22+
==== Upgrading to hyper 1.0
23+
24+
1. Update your crate's dependencies on `hyper` and `http` to 1.0 (or a newer compatible version) in Cargo.toml.
25+
2. Replace any references to `hyper::Body` with `dropshot::Body` instead.
26+
3. You may need to update your use of `dropshot::Body`; the `http-body-util` can be helpful.
27+
28+
There are no other known breaking changes in these crates that affect Dropshot. If you have any trouble with this upgrade, please let us know by filing an issue.
29+
1830
== 0.11.0 (released 2024-08-21)
1931

2032
https://github.com/oxidecomputer/dropshot/compare/v0.10.1\...v0.11.0[Full list of commits]

Cargo.lock

+55-44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dropshot/Cargo.toml

+9-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ debug-ignore = "1.0.5"
2323
form_urlencoded = "1.2.1"
2424
futures = "0.3.30"
2525
hostname = "0.4.0"
26-
http = "0.2.9"
26+
http = "1.1.0"
27+
http-body-util = "0.1.2"
2728
indexmap = "2.5.0"
2829
multer = "3.1.0"
2930
paste = "1.0.15"
@@ -55,7 +56,11 @@ version = "^0.11.1-dev"
5556
path = "../dropshot_endpoint"
5657

5758
[dependencies.hyper]
58-
version = "0.14"
59+
version = "1.4.1"
60+
features = [ "full" ]
61+
62+
[dependencies.hyper-util]
63+
version = "0.1.9"
5964
features = [ "full" ]
6065

6166
[dependencies.openapiv3]
@@ -88,8 +93,8 @@ anyhow = "1.0.89"
8893
async-channel = "2.3.1"
8994
buf-list = "1.0.3"
9095
expectorate = "1.1.0"
91-
hyper-rustls = "0.25.0"
92-
hyper-staticfile = "0.9"
96+
hyper-rustls = "0.26.0"
97+
hyper-staticfile = "0.10"
9398
lazy_static = "1.5.0"
9499
libc = "0.2.158"
95100
mime_guess = "2.0.5"

dropshot/examples/file_server.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
//! Example using Dropshot to serve files
44
55
use dropshot::ApiDescription;
6+
use dropshot::Body;
67
use dropshot::ConfigLogging;
78
use dropshot::ConfigLoggingLevel;
89
use dropshot::HttpError;
910
use dropshot::HttpServerStarter;
1011
use dropshot::RequestContext;
1112
use dropshot::{endpoint, Path};
1213
use http::{Response, StatusCode};
13-
use hyper::Body;
1414
use schemars::JsonSchema;
1515
use serde::Deserialize;
1616
use std::path::PathBuf;
@@ -133,7 +133,11 @@ async fn static_content(
133133
format!("failed to read file {:?}: {:#}", entry, e),
134134
)
135135
})?;
136-
let file_stream = hyper_staticfile::FileBytesStream::new(file);
136+
137+
let file_access = hyper_staticfile::vfs::TokioFileAccess::new(file);
138+
let file_stream =
139+
hyper_staticfile::util::FileBytesStream::new(file_access);
140+
let body = Body::wrap(hyper_staticfile::Body::Full(file_stream));
137141

138142
// Derive the MIME type from the file name
139143
let content_type = mime_guess::from_path(&entry)
@@ -143,7 +147,7 @@ async fn static_content(
143147
Ok(Response::builder()
144148
.status(StatusCode::OK)
145149
.header(http::header::CONTENT_TYPE, content_type)
146-
.body(file_stream.into_body())?)
150+
.body(body)?)
147151
}
148152
}
149153

dropshot/examples/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! Example use of Dropshot for matching wildcard paths to serve static content.
33
44
use dropshot::ApiDescription;
5+
use dropshot::Body;
56
use dropshot::ConfigDropshot;
67
use dropshot::ConfigLogging;
78
use dropshot::ConfigLoggingLevel;
@@ -10,7 +11,6 @@ use dropshot::HttpServerStarter;
1011
use dropshot::RequestContext;
1112
use dropshot::{endpoint, Path};
1213
use http::{Response, StatusCode};
13-
use hyper::Body;
1414
use schemars::JsonSchema;
1515
use serde::Deserialize;
1616

dropshot/examples/multipart.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use dropshot::endpoint;
55
use dropshot::ApiDescription;
6+
use dropshot::Body;
67
use dropshot::ConfigDropshot;
78
use dropshot::ConfigLogging;
89
use dropshot::ConfigLoggingLevel;
@@ -11,7 +12,6 @@ use dropshot::HttpServerStarter;
1112
use dropshot::MultipartBody;
1213
use dropshot::RequestContext;
1314
use http::{Response, StatusCode};
14-
use hyper::Body;
1515

1616
#[tokio::main]
1717
async fn main() -> Result<(), String> {

dropshot/src/api_description.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1312,14 +1312,14 @@ mod test {
13121312
use crate::handler::RequestContext;
13131313
use crate::ApiDescription;
13141314
use crate::ApiEndpoint;
1315+
use crate::Body;
13151316
use crate::EndpointTagPolicy;
13161317
use crate::Path;
13171318
use crate::Query;
13181319
use crate::TagConfig;
13191320
use crate::TagDetails;
13201321
use crate::CONTENT_TYPE_JSON;
13211322
use http::Method;
1322-
use hyper::Body;
13231323
use hyper::Response;
13241324
use openapiv3::OpenAPI;
13251325
use schemars::JsonSchema;

0 commit comments

Comments
 (0)