Skip to content

Commit 425a0ef

Browse files
committed
A bit more cleanup
1 parent 8cfdfb9 commit 425a0ef

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

shared-bindings/hashlib/Hash.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626

2727
#include "shared-bindings/hashlib/Hash.h"
2828

29-
// #include "shared-bindings/util.h"
30-
31-
// #include "shared/runtime/buffer_helper.h"
32-
// #include "shared/runtime/interrupt_char.h"
33-
34-
// #include "py/mperrno.h"
35-
// #include "py/mphal.h"
3629
#include "py/obj.h"
3730
#include "py/objproperty.h"
3831
#include "py/objstr.h"

supervisor/shared/web_workflow/static/serial.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function onSubmit() {
2121
input.focus();
2222
}
2323

24-
// Connect to Web Socket
2524
ws = new WebSocket("ws://" + window.location.host + "/cp/serial/");
2625

2726
ws.onopen = function() {
@@ -32,7 +31,6 @@ var setting_title = false;
3231
var encoder = new TextEncoder();
3332
var left_count = 0;
3433
ws.onmessage = function(e) {
35-
// e.data contains received string.
3634
if (e.data == "\x1b]0;") {
3735
setting_title = true;
3836
title.textContent = "";

supervisor/shared/web_workflow/web_workflow.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,16 @@ static void _reply_redirect(socketpool_socket_obj_t *socket, _request *request,
522522
"HTTP/1.1 301 Moved Permanently\r\n",
523523
"Connection: close\r\n",
524524
"Content-Length: 0\r\n",
525-
"Location: http://", hostname, ".local", path, "\r\n", NULL);
525+
"Location: ", NULL);
526+
if (request->websocket) {
527+
_send_str(socket, "ws");
528+
} else {
529+
_send_str(socket, "http");
530+
}
531+
532+
_send_strs(socket, "://", hostname, ".local", path, "\r\n", NULL);
526533
_cors_header(socket, request);
527534
_send_str(socket, "\r\n");
528-
ESP_LOGI(TAG, "redirect");
529535
}
530536

531537
static void _reply_directory_json(socketpool_socket_obj_t *socket, _request *request, FF_DIR *dir, const char *request_path, const char *path) {
@@ -853,10 +859,7 @@ static void _reply_static(socketpool_socket_obj_t *socket, _request *request, co
853859

854860
#define _REPLY_STATIC(socket, request, filename) _reply_static(socket, request, filename, filename##_length, filename##_content_type)
855861

856-
857-
858862
static void _reply_websocket_upgrade(socketpool_socket_obj_t *socket, _request *request) {
859-
ESP_LOGI(TAG, "websocket!");
860863
// Compute accept key
861864
hashlib_hash_obj_t hash;
862865
common_hal_hashlib_new(&hash, "sha1");
@@ -876,16 +879,14 @@ static void _reply_websocket_upgrade(socketpool_socket_obj_t *socket, _request *
876879
"Sec-WebSocket-Accept: ", encoded_accept, "\r\n",
877880
"\r\n", NULL);
878881
websocket_handoff(socket);
879-
880-
ESP_LOGI(TAG, "socket upgrade done");
881882
// socket is now closed and "disconnected".
882883
}
883884

884885
static bool _reply(socketpool_socket_obj_t *socket, _request *request) {
885886
if (request->redirect) {
886887
_reply_redirect(socket, request, request->path);
887888
} else if (strlen(request->origin) > 0 && !_origin_ok(request->origin)) {
888-
ESP_LOGI(TAG, "bad origin %s", request->origin);
889+
ESP_LOGE(TAG, "bad origin %s", request->origin);
889890
_reply_forbidden(socket, request);
890891
} else if (memcmp(request->path, "/fs/", 4) == 0) {
891892
if (!request->authenticated) {
@@ -1199,7 +1200,6 @@ static void _process_request(socketpool_socket_obj_t *socket, _request *request)
11991200
return;
12001201
}
12011202
bool reload = _reply(socket, request);
1202-
ESP_LOGI(TAG, "reply done");
12031203
_reset_request(request);
12041204
autoreload_resume(AUTORELOAD_SUSPEND_WEB);
12051205
if (reload) {
@@ -1217,12 +1217,10 @@ void supervisor_web_workflow_background(void) {
12171217
uint32_t port;
12181218
int newsoc = socketpool_socket_accept(&listening, (uint8_t *)&ip, &port);
12191219
if (newsoc == -EBADF) {
1220-
ESP_LOGI(TAG, "listen closed");
12211220
common_hal_socketpool_socket_close(&listening);
12221221
return;
12231222
}
12241223
if (newsoc > 0) {
1225-
ESP_LOGI(TAG, "new socket %d", newsoc);
12261224
// Close the active socket because we have another we accepted.
12271225
if (!common_hal_socketpool_socket_get_closed(&active)) {
12281226
common_hal_socketpool_socket_close(&active);
@@ -1243,7 +1241,6 @@ void supervisor_web_workflow_background(void) {
12431241

12441242
// If we have a request in progress, continue working on it.
12451243
if (common_hal_socketpool_socket_get_connected(&active)) {
1246-
// ESP_LOGI(TAG, "active connected %d", active_request.in_progress);
12471244
_process_request(&active, &active_request);
12481245
}
12491246
}

0 commit comments

Comments
 (0)