Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARN Connection header illegal in HTTP/2: connection #106

Closed
saito-kosuke opened this issue Mar 22, 2023 · 1 comment
Closed

WARN Connection header illegal in HTTP/2: connection #106

saito-kosuke opened this issue Mar 22, 2023 · 1 comment

Comments

@saito-kosuke
Copy link

I tried the sample code on the example, but the warning(WARN Connection header illegal in HTTP/2: connection) has occurred to me.

When executing the sample code without the cargo lambda, the warning didn't show.
Could someone tell me what the warning means?

use lambda_http::{run, service_fn, Body, Error, Request, RequestExt, Response};
use spider::tokio;
use spider::website::Website;

/// This is the main body for the function.
/// Write your code inside it.
/// There are some code example in the following URLs:
/// - https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/examples
async fn function_handler(_event: Request) -> Result<Response<Body>, Error> {
    // Extract some useful information from the request
    let url = "https://choosealicense.com";
    let mut website: Website = Website::new(&url);
    website.crawl().await;

    for link in website.get_links() {
        println!("- {:?}", link.as_ref());
    }

    // Return something that implements IntoResponse.
    // It will be serialized to the right response event automatically by the runtime
    let resp = Response::builder()
        .status(200)
        .header("content-type", "text/html")
        .body("Hello AWS Lambda HTTP request".into())
        .map_err(Box::new)?;
    Ok(resp)
}

#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::INFO)
        // disable printing the name of the module in every log line.
        .with_target(false)
        // disabling time is handy because CloudWatch will add the ingestion time.
        .without_time()
        .init();

    run(service_fn(function_handler)).await
}
@j-mendez
Copy link
Member

j-mendez commented Mar 22, 2023

@saito-kosuke A config to determine if the connection should be kept alive is needed to prevent the warning. It should be safe to ignore since the client ignores the headers internally. Later on I was thinking it would make sense to add a duel client that can handle http1 and http2 depending on the website and the host network. A config for website.configuration.http2_prior_knowledge was added if you know the website has http2 support to prevent using http1 connections. 9063c00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants