I am trying to build an HTTP server with an AVR + ESP8266.
I can send commands back and forth via telnet, but now I want to implement a web interface.
As a starting point I tried to setup a website that outputs "text"
however, the browser displays an empty page. Can someone please let me know the minimum requirements for the page to be interpreted as HTML?
telnet 192.168.2.26 81
Trying 192.168.2.26...
Connected to 192.168.2.26.
Escape character is '^]'.
GET / HTTP/1.1
AVR answer:
HTTP/1.1 200 OK
Content-Type: text/html
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Zeitschaltuhr</title></head>
<body>
Text
</body></html>
Connection closed by foreign host.
Minimal HTTP response:
HTTP/1.1 404
Content-Length: 0
Minimal response with content:
HTTP/1.1 200 OK
Content-Length: 12
Content-Type: text/plain; charset=utf-8
Hello World!
The reason it does not work for you is that you forgot the Content-Length: header.
Your HTTP response is missing the empty line between the response header fields and the message body (as explained here):
HTTP/1.1 200 OK
Content-Type: text/html
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Zeitschaltuhr</title></head>
<body>
Text
</body></html>
Important to provide twice CR,LF before content.
HTTP/1.1 200 OK\r\nContent-Length: 13\r\nContent-Type: text/html\r\n\r\nHello World!
Related
I am getting a 400 everytime I attempt a POST with the Telit ME910g1-WW
GET requests work great.
Here is my request:
//Check registration status
AT+CREG?
//Get the configuration of the sockets
AT#SCFG?
//Check if any socket has been activated
AT#SGACT?
//Activate the socket 1
AT#SGACT=1,1
//Wait for socket activation
WAIT=4
//Dial the socket. Port 80 is TCP connection.
AT#SD=1,0,80,"ptsv2.com"
//Wait for the CONNECT message
WAIT=4
POST /t/0ptzs-1659380654/post HTTP/1.1<cr><lf>Content-Type:application/json<cr><lf>Accept:*/*<cr><lf>Host:ptsv2.com<cr><lf>Content-Length:16<cr><lf>{"test":"test"}<cr><lf>
I am guessing it has something to do with the headers, attempted to URL encode the entire post request, but that seems to also fail.
Here is the response:
CONNECT
HTTP/1.0 400 Bad Request
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 273
Date: Tue, 02 Aug 2022 12:28:36 GMT
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>400 Bad Request</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Bad Request</h1>
<h2>Your client has issued a malformed or illegal request.</h2>
<h2></h2>
</body></html>
NO CARRIER
NO Carrier: Call dis-connected
Thanks all!
When I execute
curl -i "https://codename-one.appspot.com/token?m=id&i=d116845c6825ac151489ab33725285e5f48b3e0225285e5f48b3e02"
The result is:
HTTP/1.1 500 Internal Server Error
X-Cloud-Trace-Context: 3f022af7dc49c7650be2fa82421a8511
Date: Tue, 06 Jun 2017 18:25:36 GMT
Content-Type: text/html; charset=UTF-8
Server: Google Frontend
Content-Length: 323
Alt-Svc: quic=":443"; ma=2592000; v="38,37,36,35"
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>500 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered an error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>
This seems to happen when running the example (with six 9s) from https://www.codenameone.com/blog/new-push-servers.html
How can I tell if an old device id exists or if this is a temporary error with the servers?
That id is incorrect as the old device ids were purely numeric and your number contains both a d and an e character
Hopefully its just a quick one just ran my my first html validation everything worked exception it keeps telling me no content-type found. I've compared it to other html5 sites and I have no idea what's going on. I'm also getting a MIME error when I try to validate my CSS sheet. I'm pretty sure they're related/
http://validator.w3.org/check?uri=http%3A%2F%2Fnathansachs.com%2F&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&user-agent=W3C_Validator%2F1.3+http%3A%2F%2Fvalidator.w3.org%2Fservices
As the error message says, your server is failing to include a Content-Type header in the HTTP response. This header is mandatory. It has nothing to do with the HTML document itself.
You need to fix your server or server side program that generates your content.
% curl -I http://nathansachs.com/
HTTP/1.1 200 OK
Date: Sat, 11 Jan 2014 09:24:50 GMT
Server: Apache mod_fcgid/2.3.10-dev
Last-Modified: Tue, 07 Jan 2014 20:32:26 GMT
ETag: "bec00cb-11d5-4ef674648e9f0"
Accept-Ranges: bytes
Content-Length: 4565
I'd consider upgrading Apache. You are using an older version of a development branch. That branch has stabilised and on revision 7 now! (i.e. Apache 2.4.7 is out). Use of experimental code might be the cause of your problem.
Possibly related:
Apache2 not sending “Content-Type” in header
Try to add this inside the <head /> section.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
For HTML5:
<meta charset="UTF-8"> <!-- try without quotes as well -->
I made an action "criar" and an object "oferta" on my app. The code it came back for creating an page was:
<head prefix="og: xttp://ogp.me/ns# fb: xttp://ogp.me/ns/fb# testegraph: xttp://ogp.me/ns/fb/testegraph#">
<meta property="fb:app_id" content="186721904779529" />
<meta property="og:type" content="testegraph:oferta" />
<meta property="og:url" content="http://www.vendefacil.net:7979/mkt21manager/Welcome.jsf" />
<meta property="og:title" content="Sample Oferta" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
(i placed the metas with \ instead of < so they could be read)
I tried a direct post to OpenGraph with the following url:
url = "https://graph.facebook.com/me/testegraph:criar?oferta=http://www.vendefacil.net:7979/mkt21manager/OpenGraph/oferta.html&access_token="+vc.getAccesstoken();
The result is:
HTTP/1.1 400 Bad Request [Access-Control-Allow-Origin: *, Cache-Control: no-store, Content-Type: text/javascript; charset=UTF-8, Expires: Sat, 01 Jan 2000 00:00:00 GMT, Pragma: no-cache, WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "(#3502) Object at URL http://www.vendefacil.net:7979/mkt21manager/OpenGraph/oferta.html has og:type of 'website'. The property 'oferta' requires an object of og:type 'testegraph:oferta'. ", X-FB-Rev: 644018, X-FB-Debug: Kvtoba9EGskocz2wxI7T2iXvfzV8SvjdxNNzuYfSCp8=, Date: Wed, 10 Oct 2012 16:33:15 GMT, Connection: keep-alive, Content-Length: 252]
Seems to be complaining about the provided website not have testegraph:oferta as og:type and i know that is in the given website. So what is wrong?
According to Facebook's Debug Tool your app sends an immediate 302 redirect to
302 https://www.facebook.com/dialog/oauth?client_id=153701288088609&redirect_uri=http://www.vendefacil.net:7979/mkt21manager/Welcome.jsf&scope=email,user_photos,user_location,user_groups,status_update&response_type=code
The crawler follows the redirect, but won't scrape facebook.com URLs so the information about your page can't be updated.
You need to exempt Facebook's crawler from the redirect and serve the correct meta tags
I am doing client side testing for my web application using IE only, there is no server - so I can test my CSS/XHTML/Javascript.
When I add the line
<link rel="icon" href="favicon1.ico"/>
or
<link rel="icon"href="favicon1.ico"type="image/x-icon"/>
or
<link rel="shortcut icon"href="favicon1.ico"type="image/x-icon"/>
or
<link rel="shortcut icon"href="file://favicon1.ico"type="image/x-icon"/>
I do not see my .ico image displayed in the tab.
My favicon1.ico is a 32px by 32px (32 bpp, 8-bit alpha, no pallete) .ico file created/saved in GIMP residing in the same directory as my html files.
Pretty convinced IE needs a server at this point. I'm trying somewhat random things and using trial and error. Is there a good documentation point for this?
This is temp fix per selected answer.
<link rel="shortcut icon"href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAoCAYAAAD+MdrbAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHBRUfKj3fzL0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAFVJREFUSMftzEEKACAIRFHrZHX/Q9kmKKJS013zYXbDS0TMFFim4AACBAgQIECAAH8Ea58mZmFl+hb5r8a0qAnToGZMQp+wG/qMnVAXtkPd2IqGYANt44KonPpHX24AAAAASUVORK5CYII="/>
Try using a data URI; convert an image using an online service like this one and use that for the href value.
<link rel="shortcut icon" href="data:image/gif;base64,R0lGODlhIAAgAOf/ADEzMDo0LjY2O9oNHS09P101P1c4NTBCR2A3KHQwO8QaK4otL88aJWw3LL4gJL4gKcAhH5osMT1HO8khKdIeLURGQ9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IFEEw8hDUF1IwMGSZAiRTJTQgKGSxcmPCgIaxolFLNGJAFkpEVKHZYQnTBAgWpThby8jQtWpxHWfwUoPHEhwsDYUhZiLphgCuFnRZ9ikULFJkOL+ocEqRmCIsomDZItsAkITNDhDSp0uXIjIo/h0bJ4iSnSwcECRZEeDCjG0JFezKb0sUMho0uknBdkyVp0A1jpbjI0NCgDUI9dPYk8qSLV4XbuZHJkgPnxCZ86ML5GvEBYaAxdBL+aXYmQcUSOZxGVZJT5cAme+vKZStWxvsVOoCWs4vhwcaSL2x88UMJAYwzzzrgSPNMLcd5MYYdhDSizCUVpPACDj/ggIEAQfTTTjnoPDNMLfAcBMYVVqRBSCKLiBOHBAIQcAABAIAAzz3xWbNgKwiBocUVYtgR2yfiXKJECxVwIMU++cSX4DK1rPLaGk1YIQYdeRCSyStYYFGPPvzg42Q20oyYC0LcrFFEE1dckcYdc/AwiT/53CMPOuWUA441I86STkJ8rAEEm2JQIYQw+NhDz51OKvjLLr4oZMsZWgBRBBFYmHNPPPS8o8468WVjzaO9NLMQK31YUUQF38Qjjzxa74CKIJnAFFNqQ6HooYUOk8zjDjrqlDOriMn0EsxDtvDBRw2MxLqOOjouk0wyx2BTEjGiUHIEI/G4E44322xzDDQlliQQN6xcgoQw5JCjzTnmxivvvPTWW1JAADs=" />
I am trying to write an embedded application that serves it own web pages, and I'd like to get this working. However, I think I'm formatting the response incorrectly. Why is this not generating a fav icon in my browser tab (I'm guessing wrong Content-type or something similar):
curl -v localhost:7777/favicon.ico
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 7777 (#0)
> GET /favicon.ico HTTP/1.1
> Host: localhost:7777
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length: 1958
< Content-Type: text/html
<
* Connection #0 to host localhost left intact
<link rel="shortcut icon" href="data:image/gif;base64,R0lGODlhIAAgAOf/ADEzMDo0LjY2O9oNHS09P101P1c4NTBCR2A3KHQwO8QaK4otL88aJWw3LL4g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