biatoms / http.swift Goto Github PK
View Code? Open in Web Editor NEWA tiny HTTP server engine written in swift.
License: MIT License
A tiny HTTP server engine written in swift.
License: MIT License
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?
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.
Any chance you'd add Carthage support? This library deserves wider recognition :)
@OrkhanAlikhanov Do we have plan for upgrading 5?
I also see we specify Xcode9.3 in .travis.yml. I think it is too old.
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
Server returns incorrect response when I define two GET request with nearly same pattern.
/doctors/{id}/
/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()
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
Is it possible to call multipart requests (i.e. file upload) using this library?
Thanks
I think there may be a retain cycle here:
Http.swift/Sources/Server.swift
Lines 42 to 47 in 1d261d0
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?
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 :)
Hi,
In the source code, the iOS13 deprecated API is used for SSL/TLS. Has any plan to upgrade the framework?
Thanks.
How can we start HTTPS server?
Hi, trying run server on Iphone device (not emulator) and go to http://localhost:8080 in browser but it's not working.
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.
When I try to serve big files the server fails to serve them, Can any one fix this?
I want to connect http.swift with a directory, is it possible?
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"
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.