+ 1

HTTP Server (C code), Need Help

Hello everyone! I'm trying to create a very simple HTTP server on C. It works, but not fine :) as usual :) On the client machine chrome browser doesn't see index.html But starting to download index.html as a file, without .html As I can see the answer of server , the output is correct. It starting from "HTTP/1.1 200 OK <!DOCTYPE html> and so forth. This is the code: https://code.sololearn.com/c5hF9mBRgWQg UPD: I've just found the mistake! I have to add another "\n" after the header in the server answer. It's the requirements of HTTP 1.1 protocol! So final valid server answer is "HTTP/1.1 200 OK\r\n\n\n" and so forth. BUT I HAVE ANOTHER PROBLEM! How HTPP server sends to the client CSS file and file with javascript (index.html related)? So now my server sends to the client only html body of the page.

4th Jul 2020, 8:11 PM
Денис Филь
Денис Филь - avatar
2 Antworten
+ 2
I work out this problem. Now server works fine and sends to the client .html, .css, .js and other files with the main page of the website
7th Jul 2020, 1:27 PM
Денис Филь
Денис Филь - avatar
+ 1
OK, browser has received the html page. Parse it. And send the request to server "please 🙏 give me css and js files". Am I right? But it's only string. What text does browser send when it requests the file with css? And what text of server answer on this request?
5th Jul 2020, 12:36 PM
Денис Филь
Денис Филь - avatar