Repository: hatoo/oha (rust)

Issue:
Custom HTTP header without a space
 - H <HEADERS>                       Custom HTTP header. Examples: -H "foo: bar"
 - If I use it like -H "foo:bar" -> Error: Parse header
 - The problem is that gitlab ci schema do not allowed

```yaml
oha test:
  image:
    name: apoutchika/oha
  stage: stress_test
  script:
    - oha -V
    - oha -H "API-KEY: ${API_KEY}" https://xxx
```

- oha -H "API-KEY: ${API_KEY}" https://xxx  -> jobs:oha test sfinga:script config should be a string or a nested array of strings up to 10 levels deep

Pull request description:
Fix -H Header parser 
fixes #231 

Allow "KEY:VALUE" format

Patch:
diff --git a/src/main.rs b/src/main.rs
index ebc039b..73a908e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -207,10 +207,10 @@ async fn main() -> anyhow::Result<()> {
             opts.headers
                 .into_iter()
                 .map(|s| {
-                    let header = s.splitn(2, ": ").collect::<Vec<_>>();
+                    let header = s.splitn(2, ':').collect::<Vec<_>>();
                     anyhow::ensure!(header.len() == 2, anyhow::anyhow!("Parse header"));
-                    let name = HeaderName::from_bytes(header[0].as_bytes())?;
-                    let value = HeaderValue::from_str(header[1])?;
+                    let name = HeaderName::from_str(header[0])?;
+                    let value = HeaderValue::from_str(header[1].trim_start_matches(' '))?;
                     Ok::<(HeaderName, HeaderValue), anyhow::Error>((name, value))
                 })
                 .collect::<anyhow::Result<Vec<_>>>()?


Test patch:
diff --git a/tests/tests.rs b/tests/tests.rs
index ca80b82..29d0000 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -301,6 +301,8 @@ async fn test_enable_compression_default() {
 async fn test_setting_custom_header() {
     let header = get_header_body(&["-H", "foo: bar", "--"]).await.0;
     assert_eq!(header.get("foo").unwrap().to_str().unwrap(), "bar");
+    let header = get_header_body(&["-H", "foo:bar", "--"]).await.0;
+    assert_eq!(header.get("foo").unwrap().to_str().unwrap(), "bar");
 }
 
 #[tokio::test]