forked from rust-lang/cargo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "server" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
axum = "0.6.4" | ||
tokio = {version = "1.24.2", features = ["full"]} | ||
tower-http = {version = "0.3.5", features = ["trace", "tracing"]} | ||
tracing = "0.1.37" | ||
tracing-subscriber = {version = "0.3.16", features = ["env-filter"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
|
||
def test(n): | ||
header = b"foo" + int.to_bytes(n, 1, "little") | ||
url = "http://localhost:5000" | ||
#url = "https://crates.io" | ||
try: | ||
headers = {"Authorization": header} | ||
r = requests.get(url, headers=headers) | ||
print("Header:", header, "Response:", r.status_code) | ||
return r.status_code == 200 | ||
except ValueError as e: | ||
print("Header:", header, "Request error:", e) | ||
return False | ||
|
||
invalid = [] | ||
for i in range(256): | ||
if not test(i): | ||
invalid.append(i) | ||
|
||
print("invalid:", invalid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from flask import request, Flask | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def home(): | ||
h = request.headers | ||
print(h) | ||
return "Hi" | ||
|
||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use axum::{http::header::HeaderMap, routing::get, Router}; | ||
|
||
async fn home(headers: HeaderMap) -> &'static str { | ||
dbg!(headers); | ||
"Hello World" | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
tracing_subscriber::fmt() | ||
.with_max_level(tracing::Level::TRACE) | ||
.init(); | ||
let app = Router::new() | ||
.route("/", get(home)) | ||
.layer(tower_http::trace::TraceLayer::new_for_http()); | ||
|
||
// run it with hyper on localhost:3000 | ||
tracing::warn!("starting"); | ||
axum::Server::bind(&"0.0.0.0:5000".parse().unwrap()) | ||
.serve(app.into_make_service()) | ||
.await | ||
.unwrap(); | ||
} |