DATA_BLOB b;
/* not the most efficient http parser ever, but good enough for us */
- status = socket_recv(conn->socket, buf, sizeof(buf), &nread, 0);
+ status = tls_socket_recv(web, buf, sizeof(buf), &nread);
if (NT_STATUS_IS_ERR(status)) goto failed;
if (!NT_STATUS_IS_OK(status)) return;
b.data += web->output.nsent;
b.length -= web->output.nsent;
- status = socket_send(conn->socket, &b, &nsent, 0);
+ status = tls_socket_send(web, &b, &nsent);
if (NT_STATUS_IS_ERR(status)) {
stream_terminate_connection(web->conn, "socket_send: failed");
return;
web->output.content = data_blob_talloc(web, buf, nread);
}
- if (web->output.content.length == web->output.nsent) {
+ if (web->output.content.length == web->output.nsent &&
+ web->output.fd == -1) {
stream_terminate_connection(web->conn, NULL);
}
}
{
struct task_server *task = talloc_get_type(conn->private, struct task_server);
struct websrv_context *web;
+ NTSTATUS status;
web = talloc_zero(conn, struct websrv_context);
if (web == NULL) goto failed;
event_add_timed(conn->event.ctx, web,
timeval_current_ofs(HTTP_TIMEOUT, 0),
websrv_timeout, web);
+
+ status = tls_init_connection(web);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+
return;
failed:
status = http_setup_esp(task);
if (!NT_STATUS_IS_OK(status)) goto failed;
+ tls_initialise(task);
+
return;
failed: