Giter VIP home page Giter VIP logo

http.swift's People

Contributors

harrytranpp avatar jeff-h avatar orkhanalikhanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http.swift's Issues

Issue with api pattern

Server returns incorrect response when I define two GET request with nearly same pattern.

  1. GET doctor_profile
    API path: /doctors/{id}/
  2. GET doctor_feedbacks
    API path: /doctors/{id}/feedbacks

Problem: Call GET doctor_feedbacks but server return response for doctor_profile ( If you change adding order of two request server will works well)

Code to reproduce

let firstResponseString = "Doctor profile"
let secondResponseString = "Doctor feedback"

// Doctor profile
server.get("/doctors/{id}/") { request in
    return .ok(firstResponseString)
}

// Doctor feedbacks
server.get("/doctors/{id}/feedbacks") { request in
    return .ok(secondResponseString)
}

// Test for GET request
let ex1 = expectation(description: "test")
client.request("/doctors/{id}/feedbacks", method: .get)
    .responseString { r in
        XCTAssertEqual(r.value, secondResponseString)
        ex1.fulfill()
}
waitForExpectations()

iOS13 API deprecated

Hi,
In the source code, the iOS13 deprecated API is used for SSL/TLS. Has any plan to upgrade the framework?
Thanks.

Headers are case-sensitive

In HTTP, headers are case in-sensitive, however Http.swift treats them as case-sensitive.

This means, for example, when sending a POST to an Http.swift server with a content-length header, no body is read because Http.swift looks for Content-Length. Many clients, including fetch, use lower-case header names.

Cannot intercept all routes

Trying to intercept all routes:

server.get("/.*") { req -> Response in
    return Response.ok("Got it")
}

doesn't work. Seems to be a bug in Regex L23: (1..<result.numberOfRanges).forEach { should it start with 0?

Multipart Requests

Is it possible to call multipart requests (i.e. file upload) using this library?

Thanks

How to make client authentication

Hi,
The SSL server-authentication could be completed by run() with certificate, but there isn't interface to enable the client-authentication. How to make the client-authentication worked.
Best Regards.

Possible memory leak

I think there may be a retain cycle here:

queue.async {
while let client = try? self.socket.accept() {
self.handleConnection(client)
client.close()
}
}

I think it should be:

        queue.async { [weak self] in
            guard let self = self else {return}
            while let client = try? self.socket.accept() { 
                self.handleConnection(client) 
                client.close() 
            } 
        } 

What do you think?

Playing .mp4 encrypted video

Hi,
Can I use this framework to play encrypted video file (.mp4) using AVPlayer?

I will be running local HTTP server for this.

Regards,
Payal

SSL / TLS?

I'm using this to serve some stuff which my app then displays in a WKWebView. Given that Apple really want us using https, is SSL / TLS on your radar? I see you recently added it in the sockets dependency, so I'm hopeful :)

Carthage?

Any chance you'd add Carthage support? This library deserves wider recognition :)

how to set headers

func Webserver(){
    let server = Server()

    server.get("/hello/{id}") { request in
        request.headers = ["Server":"aichy","4":"12"]
        print(request.queryParams["state"]!)
        return .ok(request.routeParams["id"]!)
       // return
    }
  
    server.get("/"){
        request in
         request.headers = ["Server":"ios","test":"headers"]
        return .ok("hello world! ")
    }

    do{
        try server.run(port:2121)
    }
    catch{
        
    }
  
    // go to http://localhost:8080/hello/1?state=active in the browser
}

request.headers = ["Server":"ios","test":"headers"] Don't work~~thanks

How do you run the app on a different Mac without the libressl installation?

Running the app seems to require libressl brew installation (it's a bit confusing since the package includes cLibreSSL), once installed it runs well but running the app in another Mac requires the library installation.

How are you supposed to run the app in other Macs so the app embeds the library it needs and doesnt require the installation in every Mac?

How to use Http.Swift

hi, i have installed your Framework, now I tried to C/P your readme `let server = Server()
server.get("/hello/{id}") { request in
print(request.queryParams["state"])
return .ok(request.routeParams["id"]!)
}

try server.run()`

but I have an error on server.run : "Error thrown from here are not handled"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.