Skip to content

Commit ac0f11f

Browse files
committed
upgraded to v0.0.77
1 parent 31b0139 commit ac0f11f

File tree

3 files changed

+8
-71
lines changed

3 files changed

+8
-71
lines changed

libs/http/index.b

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ def delete(url) {
140140
}
141141

142142
/**
143-
* server(port: int, address: string, is_secure: bool)
143+
* server(port: int, address: string)
144144
*
145145
* Creates an new HttpServer instance.
146146
* @returns HttpServer
147147
* @throws Exception, SocketExcepion, HttpException
148148
*/
149-
def server(port, address, is_secure) {
150-
return HttpServer(port, address, is_secure)
149+
def server(port, address) {
150+
return HttpServer(port, address)
151151
}

libs/http/request.b

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import curl {
2020
CurlMime,
2121
Auth
2222
}
23-
import ssl
2423

2524
/**
2625
* Http request handler and object.
@@ -326,8 +325,8 @@ class HttpRequest {
326325

327326
if !is_string(raw_data)
328327
die HttpException('raw_data must be string')
329-
if !instance_of(client, socket.Socket) and !instance_of(client, ssl.TLSSocket)
330-
die HttpException('invalid Socket or TLSSocket')
328+
if !instance_of(client, socket.Socket)
329+
die HttpException('invalid Socket')
331330

332331
self.ip = client.info().address
333332

libs/http/server.b

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,13 @@ import .status
77

88
import socket as so
99
import iters
10-
import ssl
1110

1211
/**
1312
* HTTP server
1413
* @printable
1514
*/
1615
class HttpServer {
1716

18-
/**
19-
* A boolean value indicating if the server should/will be TLS/SSL secured or not.
20-
* @default false
21-
*/
22-
var is_secure = false
23-
2417
/**
2518
* The host address to which this server will be bound
2619
* @default socket.IP_LOCAL (127.0.0.1)
@@ -62,20 +55,6 @@ class HttpServer {
6255
*/
6356
var write_timeout = 2000
6457

65-
/**
66-
* The SSL/TLS ceritificate file that will be used be used by a secured server for
67-
* serving requests.
68-
* @note do not set a value to it directly. Use `load_certs()` instead.
69-
*/
70-
var cert_file
71-
72-
/**
73-
* The SSL/TLS private key file that will be used be used by a secured server for
74-
* serving requests.
75-
* @note do not set a value to it directly. Use `load_certs()` instead.
76-
*/
77-
var private_key_file
78-
7958
/**
8059
* This value controls whether the client certificate should be verified
8160
* or not.
@@ -96,10 +75,10 @@ class HttpServer {
9675
var _error_listeners = []
9776

9877
/**
99-
* HttpServer(port: int [, host: string [, is_secure: bool]])
78+
* HttpServer(port: int [, host: string])
10079
* @constructor
10180
*/
102-
HttpServer(port, host, is_secure) {
81+
HttpServer(port, host) {
10382

10483
if !is_int(port) or port <= 0
10584
die HttpException('invalid port number')
@@ -109,39 +88,7 @@ class HttpServer {
10988
die HttpException('invalid host')
11089
else if host != nil self.host = host
11190

112-
if is_secure != nil and !is_bool(is_secure)
113-
die Exception('is_secure must be boolean')
114-
if !is_secure is_secure = false
115-
116-
self.socket = !is_secure ? so.Socket() : ssl.TLSSocket()
117-
# self.socket = so.Socket()
118-
self.is_secure = is_secure
119-
}
120-
121-
/**
122-
* load_certs(cert_file: string | file [, private_key_file: string | file])
123-
*
124-
* loads the given SSL/TLS certificate pairs for the given SSL/TLS context.
125-
* @note certificates can only be loaded for secure servers.
126-
* @return bool
127-
*/
128-
load_certs(cert_file, private_key_file) {
129-
if !self.is_secure
130-
die HttpException('certificates can only be loaded for secure servers')
131-
132-
if !private_key_file private_key_file = cert_file
133-
134-
self.socket.get_context().set_verify(self.verify_certs ? ssl.SSL_VERIFY_PEER : ssl.SSL_VERIFY_NONE)
135-
136-
if self.socket.get_context().load_certs(cert_file, private_key_file) {
137-
self.cert_file = cert_file
138-
self.private_key_file = private_key_file
139-
140-
return self.socket.get_context().set_ciphers(self._ciphers)
141-
} else {
142-
# die Exception('could not load certificate(s)')
143-
return false
144-
}
91+
self.socket = so.Socket()
14592
}
14693

14794
/**
@@ -153,8 +100,6 @@ class HttpServer {
153100
self._is_listening = false
154101
if !self.socket.is_closed
155102
self.socket.close()
156-
if self.is_secure
157-
self.socket.get_context().free() # close the TLS socket context.
158103
}
159104

160105
/**
@@ -291,13 +236,6 @@ class HttpServer {
291236
* connection from HTTP clients.
292237
*/
293238
listen() {
294-
if self.is_secure {
295-
if !self.cert_file
296-
die HttpException('no certificate loaded for secure server')
297-
if !self.private_key_file
298-
die HttpException('no private key loaded for secure server')
299-
}
300-
301239
if !self.socket.is_listening {
302240
self.socket.set_option(so.SO_REUSEADDR, is_bool(self.resuse_address) ? self.resuse_address : true)
303241
self.socket.bind(self.port, self.host)

0 commit comments

Comments
 (0)