Skip to content

lantos1618/nim-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nim_http

An alternate http client for nim why?

  • add unix socket support
  • add ability to recv stream data in sync that doesn't require the body to finish
  • sync and async api

Todo

  • http2 support
  • add more tests
  • add multipart support
  • add more examples
  • add proxy support
  • add send body
  • add send body in chunks
  • add ssl support
  • add unix socket support
  • add data stream and iter chunk support
  • convert code to multisync
  • add http error raising (?) probably not

Usage

import nim-client

proc main() =
  let client: HttpClient
  let resp = client.fetch(HttpGet, "https://httpbin.org/get")
  
  case resp.httpCode:
  of Http200:
    # data iterator 
    for data in resp.body():
        echo data
    ## get body all at once  
    # resp.body()
    ## data stream
    ## happens all at once
    #resp.recvStream()
    ## then this happens
    #resp.stream.readAll()
  else:
    raise 
 
proc mainAsync() {.async.} =
  let client: AsyncHttpClient
  let resp = await client.fetch(HttpGet, "https://httpbin.org/get")
  for data in resp.body():
    echo data

when isMainModule:
  main()
  mainAsync()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages