Hmmm, I get only one Host header locally with netcat: 
    
    
    POST / HTTP/1.1
    Connection: Keep-Alive
    content-length: 20
    content-type: application/json
    host: other-url.com
    user-agent: Nim httpclient/1.4.4
    
    {"data":"some text"}
    
    
    Run

Code: 
    
    
    import httpclient, json
    
    let client = newHttpClient()
    client.headers = newHttpHeaders({"Content-Type": "application/json",
        "Host": "other-url.com"})
    let body = %*{
        "data": "some text"
    }
    let response = client.request("http://localhost:1234";, httpMethod = 
HttpPost, body = $body)
    echo response.status
    
    
    Run

Maybe something is wrong with header casing? Try with `titleCase = true`:
    
    
    client.headers = newHttpHeaders({"Content-Type": "application/json", 
"Host": "other-url.com"},  titleCase = true)
    
    
    Run

Reply via email to