http response in arduino code - http

I kind of have a weird problem whith an arduino code.
Here is my code : http://pastebin.com/MnVAX0yj
This code allow me to take temperatures every x seconds, store it in a file and then be able to get that file back through html requests.
I'd like to be able to change the mime of the answer according the exension of the file asked in the http request. So it would be nice if I could uncomment the lines 196-198. But if I do so, when I try to get the file through a browser I get the 404 error message from line 174. It is really weird...
A second thing I would like to be able to, is add a "Access-Control-Allow-Origin: *" line in the http response. So I would like to uncomment the line 192. But if I do so, I also get the same 404 error message from line 174. It is also really weird !
Any idea to solve that problem ?
I hope any of you could help me, it's the final step to finish my project !
Thank you
Tuxben

Related

Cannot modify header information -wordpress

how can I solve this error?
Warning: Cannot modify header information - headers already sent by (output started at /home/content/33/11887833/html/fixoye/wp-includes/class-wp-roles.php:1) in /home/content/33/11887833/html/fixoye/wp-includes/pluggable.php on line 1228
Since you haven't provide your code, it is difficult to figure out what is the problem exactly & where it is. Here are some of common root problems that leads to these kind of errors.
Usually this error message gets prompts when some output is sent before to your HTTP headers are sent.
Here are some frequent causes to the type of errors
If there are white spaces at the beginning or end of files
<?php
// Note: There is a space before "<?php"
?>
Printing output before sending the headers
printing
echo
printf
readfile
passthru
print
vprintf
trigger_error
ob_flush
ob_end_flush
var_dump
print_r
flush
imagepng
imagejpegcodes
before sending headers.
<?php
echo "something";
header("Location:index.php");
?>
Sometimes cause can be a warning message outputted by php
display_errors php.ini property will silently fixes the error and emits a warning instead of crashing on a programmer mistake. so before the header, that warning may be move first.
NOTE : What you should find out is, where the place that the application outputs an HTTP body before the HTTP header.
There is a nice article about this problem 'PHP development: why redirects don't work (headers already sent)', by Adobe
And also this answer in stackoverflow also points outs many error points How to fix “Headers already sent” error in PHP
Fixed it. just replaced the functions.php file of our theme with the original file or backup file.
or
Simply take the wp-config.php file, open it in a text editor and click save as. It will try to save as UTF-8 file, save it as ANSI.
or
fixed this by removing
from your header.php file

Custom text for HTTP API status code

I am writing a new endpoint in my HTTP service that is built on the Play framework, and am returning a custom status code for a particular error (442 in this case). When I test the endpoint with cURL, I receive the error code as expected:
...
< HTTP/1.1 442 Client Error (442)
....
And the same with Postman REST Client:
What I would like to do is customize the "Client Error" text, such that the response would actually read something like:
442 Forced Password Reset
Is this possible, or is it in the spec somewhere that any custom status codes of the 4xx class are to be interpreted by all clients simply as "Client Error"?
(I have been looking through the relevant Play documentation on Statuses but don't see any option to customize the text—only the status code integer itself.)
Looking through the source code it didn't take me long to find the following:
Play just stores the status code in the RepsonseHeader, not the string
Play uses Netty, and turns the status code into a HttpResponseStatus using valueOf, which is basically just a case statement over the status codes, with defaults based on the range if it isn't standard.
Although you could define a new Netty HttpResponseStatus with the reason phrase you want, there isn't any way to add it to the valueOf method (it's static).
So, there isn't any really good solution without rewriting some parts of Play!.
You might be able to use some sort of post-filter to modify the response and change the reason phrase, but I don't know how that would work, or even if it is possible to write those kinds of filters in Play!.
Finally, the reason phrase isn't really that important, as clients generally don't (and shouldn't) actually parse it.

Error code redirect when returning a response with chunked encoding?

My web application uses chunked encoding. I'd like to have the behavior where if any chunk generates an error, I can properly set the error code and redirect to an error page using that. Right now it seems like that can only happen if the error occurs during the first chunk because the response headers must be sent in the first chunk. Is there any way to make this work or get the behavior that I want? Thanks.
The HTTP spec allows you to provide additional headers as a "trailer" after your last chunk, which should be treated just like headers at the top of the response:
https://www.rfc-editor.org/rfc/rfc2616#section-3.6.1
Here's an example:
http://www.jmarshall.com/easy/http/#http1.1c2

Why does a percent symbol in a get request break my site?

I feel pretty stupid for asking this, but I'm doing a form where the user enters some input and sometimes the input is a percent symbol, say 5%. When this gets passed along as part of a GET request, like this:
http://kburke.org/project/company_x/?id=4&var1=1&ops=23255&cashflow=25000&growth=5%25&pv=100000&roe=20&profitmargin=30&roe=80&turnover=2
I get a 404 Page Not Found error. When I remove the query string pair
&growth=5%25
the page loads fine. Can someone help explain what the problem is?
Edit: I tried removing all of the Javascript from the page and the server still craps out. I also just tried running it in MAMP as
http://localhost:8888/project/company_x/?id=4&var1=1&ops=23255&cashflow=25000&growth=5%25&pv=100000&roe=20&profitmargin=30&roe=80&turnover=2
and it worked fine. I'm wondering if it's a problem with my own server. When I open Firebug to the console and run the page, I see an error very briefly and then the 404 page loads - is there a way I can pause the redirect so I can read the error message?
Check out URL ENCODING. The "%" character in a url means something special.
You encode the space character ' ' as %20 in a url.
You encode the percent character '%' as %25 in a url.
So after your url gets to the script, your argument 'growth' will equal "5%".
I tried messing around with your url and it appears that your script is crashing when it tries to parse the growth argument, and your web site is hiding that crash from you by sending you to the 404 page. I'd post your script code if you need more help.

Actionscript error

I have a flex application which is configured with blazeds sever and i am pulling images from remote database from my flex application, but as soon as i click the get image button to pull images it is giving some action script error.
TypeError: Error #2007: Parameter bytes must be non-null.
at flash.display::Loader/_loadBytes()
at flash.display::Loader/loadBytes()
I tried googling but couldn't found any solution.
Any help is appreciated.
You have a null parameter inside the function flash.display::Loader/loadBytes(). ;)
Short answer is that you're probably fetching the wrong url. Use firebug or Fiddler or something to determine whether the url is correct. If that's not the case, maybe you're not handling the right events.
Like the comments say, we need the code.
Thank You everyone it was a my code error, it give this error if no value is returned to load bytes . I was pulling a image from a table where no image was present and therefore returning null value in load bytes.

Resources