Skip to content

Commit

Permalink
Add sensible defaults to additional HEADER prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Sep 11, 2024
1 parent cd745aa commit f8ae01c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion h3i/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn config_from_clap() -> std::result::Result<Config, String> {
.arg(
Arg::with_name("omit-sni")
.long("omit-sni")
.help("Send an empty SNI in the TLS handshake.")
.help("Omit the SNI from the TLS handshake")
// Requires an OsStr, so we can parse to empty later on
.takes_value(false)
)
Expand Down
27 changes: 27 additions & 0 deletions h3i/src/prompts/h3/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
// Copyright (C) 2024, Cloudflare, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

//! QUIC and HTTP/3 errors for the h3i client.
use inquire::error::InquireResult;
use inquire::validator::Validation;
use inquire::CustomUserError;
Expand Down
11 changes: 3 additions & 8 deletions h3i/src/prompts/h3/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub fn prompt_push_promise() -> InquireResult<Action> {
fn pseudo_headers(host_port: &str) -> InquireResult<Vec<quiche::h3::Header>> {
let method = Text::new("method:")
.with_autocomplete(&method_suggester)
.with_default("GET")
.with_help_message(ESC_TO_RET)
.prompt()?;

Expand All @@ -126,10 +127,10 @@ fn pseudo_headers(host_port: &str) -> InquireResult<Vec<quiche::h3::Header>> {
.with_help_message(&help)
.prompt()?;

let path = Text::new("path:").prompt()?;
let path = Text::new("path:").with_default("/").prompt()?;

let scheme = Text::new("scheme:")
.with_autocomplete(&scheme_suggester)
.with_default("https")
.with_help_message(ESC_TO_RET)
.prompt()?;

Expand Down Expand Up @@ -170,12 +171,6 @@ fn method_suggester(val: &str) -> SuggestionResult<Vec<String>> {
squish_suggester(&suggestions, val)
}

fn scheme_suggester(val: &str) -> SuggestionResult<Vec<String>> {
let suggestions = ["https"];

squish_suggester(&suggestions, val)
}

fn validate_stream_id(id: &str) -> SuggestionResult<Validation> {
if id.is_empty() {
return Ok(Validation::Valid);
Expand Down

0 comments on commit f8ae01c

Please sign in to comment.