\"Finally\", Sortix continued, \"someone completed a working HTTP server that runs under Sortix, which runs as a virtual machine, that communicates over a serial terminal driver to proxy server that communicates with the real internet!\".
\n" "Sortix was happy.
\n" "This website was served by a server running under my very own operating system, which is connected to the internet through a serial modem driver. Heh!
\n" " \n" "\n" ; Respond(Response, String::Length(Response)); return; } else { const char* Response = "HTTP/1.1 400 Not Found\r\nConnection: close\r\n\r\nHTTP 404 File Not Found\n"; Send(Response, String::Length(Response)); Close(); return; } } void HandleConnection() { char Buffer[1024]; char* Operation = NULL; char* Resource = NULL; size_t Used = 0; nat State = 0; while ( true ) { if ( !TryByte(Buffer + Used) ) { return; } Used++; Buffer[Used] = '\0'; if ( State == 0 ) { if ( Used >= 4 ) { if ( Buffer[0] == 'G' && Buffer[1] == 'E' && Buffer[2] == 'T' && Buffer[3] == ' ' ) { State++; Buffer[3] = '\0'; Operation = Buffer; } else { const char* Response = "HTTP/1.1 501 Not Implemented\r\nConnection: close\r\n\r\nThis request is not supported by this server!\n"; Send(Response, String::Length(Response)); Close(); return; } } } if ( State == 1 ) { if ( Buffer[Used-1] == ' ' ) { Resource = Buffer + 4; Buffer[Used-1] = '\0'; State++; break; } } if ( Used == 1024 ) { const char* Response = "HTTP/1.1 400 Bad Request\r\n\r\n"; Send(Response, String::Length(Response)); Close(); return; } } nat LineChars = 0; while ( LineChars < 4 ) { char TMP; if ( !TryByte(&TMP) ) { return; } if ( TMP == '\r' || TMP == '\n' ) { LineChars++; } else { LineChars = 0; } } HandleResource(Operation, Resource); } void Init() { Left = 0; while ( true ) { HandleConnection(); } } } }