receive json in a iframe blackberry 5 - html

hi i'm trying to upload a image from an iframe and is working, but cant get the response from the server, i try to set the target of the form to _blank and i get an promp to save the file instead of displaying it as html or plain txt when trying to open the saved file blackberry alerts "can display file" but if i send the file over Bluetooth and open it in mi pc it have the valid server response,i think that is the mime types that are preventing the iframe to load but i don't know if i'm correct
this are the header that the server return:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Fri, 24 Feb 2012 00:31:06 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=61
Pragma:no-cache
Server:Apache/1.3.42 (Unix) mod_jk/1.2.30 mod_gzip/1.3.26.1a mod_log_bytes/1.2 mod_bwlimited/1.4 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.17
i get the header from a desktop chrome
i'm doing after hours to get this fixed but i canĀ“t figure out how to work around this any help will be appreciated thanks
update
i try the mime type stuff and i can reproduce the problem seting the json mime type to an arbitrary document whit this code
<?php header('Content-type: application/json'); ?>
and as spected i get de "culd no load" alert on blackberry, is there any way i can force it to show the json as plain text so i can later parse it?

Probably too late to help you out but maybe this will help someone else...
Essentially when you send text back to an empty iframe, the browsers are looking at the incomming data and if its not HTML they're wrapping tags around it.
If you change your header to content-type: text/html the browsers will not populate the iframe with html and you get the raw json.

Related

BigCommerce [{"status":415,"message":"The specified input content type is not valid."}]

Trying to create a product rule using Postman on BigCommerce. All my other queries to BC work fine but on this one I receive the
[{"status":415,"message":"The specified input content type is not valid."}]
Doesn't seem to matter what is in the actual body, even if it is empty.
call:
https://api.bigcommerce.com/stores/xxxxxxxxx/v2/products/34371/rules
headers:
X-Auth-Client:xxxxxxxxxxxxxxxxxxxxxxxx
X-Auth-Token:xxxxxxxxxxxxxxxxxxxxxxx
Accept:application/json
Content-Type:application/json
I found that the issue was with Postman.
Postman was changing Content-Type: application/json to multipart/form-data behind the scenes.

How to send Email sending without html format

I send email in rails using mailer.It send successfully.But the way it send is not proper.It is sending in html tags like that
Sent mail to xxx (3.6ms)
Date: Mon, 09 Nov 2015 14:53:15 +0500
From: from#example.com
To: xxx
Message-ID: <56406d0b15b8e_6f03f8d3408607861097#des-0071.mail>
Subject: Password Reset
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<body>
<p>Hello </p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p>Change my password</p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
</body>
</html>
File is password_reset.html.erb
In rails console, you can see the html tag actually. But in the real email you could not see those HTML tags. Try to run not using console but run actually how do you want it to call. Use mailcatchergem to see real results of the email.
In short, you can install and run like this:
gem install mailcatcher
run mailcatcher to your bash.
Go to browser: http://localhost:1080/
Then you can see like this image.
The email client will render those tags once the email is received by the user and you will not see any of them. An email template is treated very much like a View in Rails. if you take everything between <html> and </html> and save it in a file and open it in a browser, that's what the email will look like for the user.
Also you want to send an absolute path in your email link, that is a relative link you have right now and if the user clicks it outside your website (from an email client) it will not work.

How can I force a link to a PDF to tell the browser to download it as a PDF?

My application generates a dynamic link to any PDF files that are associated with a product. The link is presented like this:
Brochure
If the user right-clicks and selects "Download Linked File As" (or its equivalent), the file is presented with a ".pdf.png" extension in Google Chrome and Safari. Firefox works appropriately, not sure about Internet Explorer.
I want Firefox and Chrome to know that it is a PDF. Because obviously users are going to try to download these, they are going to save it with the wrong extension, and they won't be able to open the file.
Assuming you are using "send_data" from within a rails controller to serve the file might I suggest:
send_data(
data,
:filename => "filename.pdf",
:disposition => "attachment",
:type => 'application/pdf'
)
Where "data" is the contents of the PDF.
For more information checkout the following link:
http://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_data
send proper headers in some scripting lang like php or user .htaccess
<Files *.pdf>
ForceType application/pdf
Header set Content-Disposition attachment
</Files>
Have you heard of the content-disposition header? It allows you to tell the browser to ask the user what to do with the file, rather than try and handle it by itself. I don't think it is part of the HTTP spec, but it is documented by the IETF under RFC 2183.
You should be able to use whatever language you are using to alter the HTTP headers before they go to the client. The header you add will look something like this:
Content-Disposition: attachment; filename=filename.pdf
You might also need a Content-Type header:
Content-Type: application/pdf

HTML link that bypasses cache?

I have a file that I link to from my website like
<a href="http://example.com/myfile.txt>View!</a>
However, this file changes very frequently and when the link is clicked, the browser loads the cached version of the file, not the actual file.
Is there a way so that clicking on that link will bypass the cache for that page?
Something nice like <a bypassCache href=""> would be wishful thinking.
Something nice like would be wishful thinking.
Indeed, there is something you can do from within the link: Add a random GET parameter.
View!
You could use JavaScript (or of course a server-side scripting language like PHP) to do this on a dynamic basis.
However, the far superior way would be to configure the text file's caching headers correctly in the first place on server side. Stealing the header info from Best way to disable client caching, a .htaccess file like this should work:
<Files myfile.txt>
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "store, no-cache, must-revalidate, post-check=0, pre-check=0"
Header set Pragma "no-cache"
Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
</IfModule>
</FilesMatch>
Just put
<meta http-equiv="expires" content="0">
Into the head section of your target page and check again
The best way is to tell apache/(web server) to tell browser not allow caching of that file, if you don't have controll over that server, you could avoid cache by alter the parameters send to it, just add some numbers behind ?, for exemple the time when you created the link, this makes each url diferent, so the browser going to ignore the cache, but all links to the same file, as long as the server ignore the extra parameter. in php:
echo "<a href='http://example.com/myfile.txt?" . time() . "'>View!</a>"
Add a random number after the hyper link, such as View!
Generate a new random number each time the page loads.
You can solve your problem on server level. Set the special expiration date for txt resources (or that particular one) that fit to your requirements.
If you use apache you can read about mod_expiry for apache here

Making sure the page is reloaded on going back

at least in chrome, when i hit the back button, it doesn't actually reload the page, it just uses a stored copy i guess. How can i ensure that when someone does this, the page is reloaded?
In PHP you would do this:
header('Expires: Mon, 20 Dec 1998 01:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
However, the names of the headers sent would be the same for any server-side programming language as they all eventually go over HTTP to the client.
See Wikipedia's List of HTTP Headers for information about each of these.
I haven't tried it, but you could try to send a Cache-Control HTTP header with your file. For example in PHP:
header('Cache-Control: no-cache,no-store,max-age=0');
This will tell your browsers (and caches along the way) not to cache this file under any circumstance. But delivering the previous file on clicking the back button is not necessarily considered caching and so might ignore such headers.
If you really want to avoid the back button you can try do to it with Javascript. I really don't recommend this approach - and you should step back and think about why you want to do this. That said, something like this code in your HTML body should work:
<input type="hidden" id="back_button" value="0" />
<script>
var bb = document.getElementById('back_button');
if (bb.value !== '0') {
location.href = location.href + '?rand=' + parseInt(Math.random()*9999);
}
bb.value = '1';
</script>
This will open the current page but with a 'rand' query string parameter appended to bust any caches.
If you are in the asp.net world I believe all you should need to do is
Response.Cache.SetCacheability(HttpCacheability.NoCache)
In your Page_Load