Allowing HTTP API calls in Chrome - api

I am writing a test JSP-Servlet page that calls an HTTP API. But when I run the call in Chrome browser it is converting the call to HTTPS and the call fails. The API is not mine and the developer of the API insists that the call has to be on HTTP.
So is there a way to allow this API call using HTTP and prevent Chrome from converting it to an HTTPS call?
Note: I checked the Web and all are saying to change the browser settings. But we will not be able to tell each and every user of our site to do so!

Add this Script on top of your JSP File!
<script>
if (location.protocol == "https:") {
location.protocol = "http:";
</script>
Note:
First, location.protocol checks Url
and the second location.protocol will change it to http.
This will redirect your Client. If he visits your website as https: it will redirect him as http:

Related

Find the HTTP method used to open a new page in Selenium

I am using Selenium with Python and Behave to test a web application. I could not figure out what HTTP method my web application uses to open a new page in a new tab using Selenium. Our application integrates with many internal microservices and we have the UI that makes an API call upon a click event and the the api response for a given call would come back with a URL to redirect to and the HTTP method to use for the redirect.
In my test I want to assert the URL that we redirect to and the HTTP method(GET/POST) our web application used in the new tab to redirect to. I was able to switch to the new tab and assert the URL but not the HTTP method.
Has anyone run into this? Thanks in advance

Is there any way to clear cache in JS level. need to clear browser cache/ session and cookies

I have a http call to an api, the first call is ok, during using the application there are https calls under same domain. even though consequence https calls are not happening within webview but all http url under the same domain will redirect to https in the webview.
You can work this out through the React Native built-in module.
You can use RCTNetworking
var RCTNetworking = require("RCTNetworking");
RCTNetworking.clearCookies();

Is it possible to make a cross domain request from https to http in IE?

We are trying to access a local self-hosted WCF service from the browser.
The WCF service is located at http://localhost/myWcf.
The browser is running a website which is located at https://some.www.com.
We have enabled CORS and added CORS header to the hosted WCF. Access to the WCF service is done using jQuery’s $.ajax call. All browsers are working fine when not using SSL and we’re getting to the “success” callback.
When switching to SSL, IE is the only one that fails to make the request – “Access is denied”. We moved the website to the trusted sites section and basically allowed everything there and still no go. We’re using IE11/10 and we've tried previous versions through its emulator. None of them allows us to make that request.
We can address a picture that located in http from https like this:
<img src="http://asdasd">
but we try to use javascript it fails:
var img = new Image();
img.src="http://asdasd";
What are we missing? Is it really impossible to make a cross domain request from https to http in IE?
Check jsonp:
var script = document.createElement('script');
script.id = 'dynScript';
script.type='text/javascript';
script.src = 'http://localhost/myWcf';
document.getElementsByTagName('head')[0].appendChild(script);
JSONP is a great away to get around cross-domain scripting errors.

passing login credentials via iframe

I have two different domains/sites, one http and one https. The http site requires login and then users are shown a non-secure page with an iframe that shows content from the https site.
I would like to seamlessly pass login credentials from the http site to the iframe'd https site. I do not want to use jquery. Is it possible to have the iframe use a POST request instead of GET? I would like to encrypt the login info from the http site and POST the encrypted bundle to the https site.
I'm working with php and apache, if it makes a difference.
I found this article on iframe/POST but wasn't sure how to get the form auto-submitted when the http page loads. Maybe that's a line of javascript? Also, while the login page on the http site has a login form, the post-login page that has the iframe on it does not (currently) have a form. Maybe I could make an invisible form to create this POST request?
Thanks!
You can use Javascript like this:
document.getElementById('someId').submit();

Are there any samples/tutorials which tells how to call servlets on J2EE server from iPhone app?

Sorry for posting basic question but please give me your advise.
I have to write iOS application which communicates with web application deployed on Tomcat server.
The web application requires client-app to call the "logon" servlet with username and password to get JSESSIONID. Once client get JSESSIONID, the web application allows to invoke other servlets.
But I couldn't figure out how to manage the session to invoke these servlets.
Would you please introduce me the examples/tutorials to learn how to invoke these kind of servlets?
Thank you in advance.
Here's a decent example of making an http request from iOS:
iOS: How to make a secure HTTPS connection to pass credentials?
There's nothing magic about making the call to a j2ee tomcat server - it's just an HTTP request, so any way you can make an HTTP request will work for you.
Maybe this one too:
Can I make POST or GET requests from an iphone application?
edit: ahh, looks like this is the one you want:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
The JSESSIONID is nothing special. If your application is set up to handle cookies coming back from your HTTP request then the JSESSIONID will come back as a cookie in the header. Otherwise you will be issued a redirect to a URL with the JSESSIONID in it. From there, if you handle cookies, the JSESSIONID will be passed automatically with each request with all of the other cookies. Otherwise you'll have to put it into the URL of each request manually.
Download the liveheaders plugin for Firefox and try hitting your servlet with the webbrowser and you can see how the JSESSIONID gets passed around. Next, turn off cookies in Firefox and you can see how it's passed around in the URL and you can see the redirect that Tomcat issues if you watch the headers in liveheaders.