Author Topic: uTasker Webserver  (Read 5852 times)

Offline kingston

  • Newbie
  • *
  • Posts: 26
    • View Profile
uTasker Webserver
« on: June 14, 2012, 01:14:20 PM »
Hello,

I have a strange problem with the uTasker webserver. I'm using a Kinetis K60 and have put my website "index.htm" in "dir1" on the sd-card.
When I try to open the website by typing in the ip it serves the html source code.
When I explicitly call 192.168.2.7/index.htm it works and the website gets displayed.
Has anybody experienced this and maybe knows a fix?

Thanks

Paul

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: uTasker Webserver
« Reply #1 on: June 14, 2012, 02:08:55 PM »
Hi Paul

When you write that it "serves the html source code" do you mean that the content is seen like HTML in a text editor rather than being displayed as a browser would normally see it?

If this is the case try different browsers to see if it is restricted to some of them or whether the behaviour is general.

When the browser requests a page like index.htm it know that it expects the content to be HTML. When, however, no file is given it doesn't know what content to expect and it may be using the mata data returned in the header of the HTML in identify the content. Check the header details (eg. <meta http-equiv="content-type"content="no-cache"content="text/html"> in the head of your index.htm to ensure that it is not confusing the browser, or is missing.

Regards

Mark



Offline kingston

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: uTasker Webserver
« Reply #2 on: June 15, 2012, 07:20:48 AM »
Hi Mark,

yes the content is seen like in a text editor. I tried IE and it works like it should so the problem is with FF and how it requests the page.
The meta tag should be right so I have to investigate whats the difference between the two browser methods.

Thanks

Paul

EDIT:

It looks like the content-type is not reported in the http header so FF and Safari just show plain text.
Safari even displays plain text when the htm file is called directly.
I saw in "http.c" that the HTTP header should always contain the content type but with FF-addon HTTP Live-Header I only get "OK" as a response and nothing about content.

Code: [Select]
#ifdef SUPPORT_CHROME                                                    // {34} Chrome requires that the web server always sends a HTTP header otherwise it refuses to operate
    static const CHAR cucHTTP_header[] = "HTTP/1.0 200 OK\r\n\r\n";
    #define SIMPLE_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_header) - 1)
    static const CHAR cucHTTP_plain_text[] = "Content-Type: text/plain\r\n\r\n"; // {45}
    #define TEXT_PLAIN_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_plain_text) - 1)

I tried changing the "text/plain" to "text/html" in the above code but no change as it seems this doesn't even get transfered.
I will try chrome and opera next but guess the results will be the same.


EDIT #2:
I edited the code as follows and now it works!

Code: [Select]
#ifdef SUPPORT_CHROME                                                    // {34} Chrome requires that the web server always sends a HTTP header otherwise it refuses to operate
    static const CHAR cucHTTP_header[] = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"; //Original     static const CHAR cucHTTP_header[] = "HTTP/1.0 200 OK\r\n\r\n"; ¿
    #define SIMPLE_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_header) - 1)
    static const CHAR cucHTTP_plain_text[] = "Content-Type: text/plain\r\n\r\n"; // {45}
    #define TEXT_PLAIN_HTTP_HEADER_LENGTH    (sizeof(cucHTTP_plain_text) - 1)

as this is really quick and dirty I hope there is another workaround for it.

« Last Edit: June 15, 2012, 08:31:59 AM by kingston »