swf file in https zone, upload script in http zone.
File upload fine in ie, and not work on firefox, opera.
this code:
request.url = this.main.serverHostUpload + "/upload_web.php";
request.method = URLRequestMethod.POST;
request.contentType = "multipart/form-data; boundary=" + UploadPostHelper.getBoundary();
request.data = new URLVariables();
request.data.dst_file = fileDstName;
request.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );
var fr:FileReference = this.main.photos[this.iLoadPh].fr;
fr.cancel();
fr.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,createOrderStep6Res);
fr.upload(request,"file");
I have had similar problems and sometimes it is the quality of the cert if you are posting over https. You also should make sure that fileference is calling a URL with the actual port number (443 for https).
I have also seen fire reference reconnect in browsers other than IE. You can spot this using something like Tamper Data for Firefox or Fiddler to get a NIC-level view of it.
Related
In the Appium wiki page (https://github.com/appium/appium/wiki/Automating-mobile-gestures) the following endpoints are mentioned:
session/:sessionId/touch/tap
session:/sessionId/touch/flick_precise
session:/sessionId/touch/swipe
However, when using TouchActions of the newest Java bindings of WebDriver (2.35):
A call to "singleTap", calls /touch/click (i.e., not "tap"). Which, in my application at least, causes the Appium server to output an error and drop the client without notifying it, so the client just hangs.
A call to "flick", calls /touch/flick (instead of "flick_precis"), which works fine.
Which is endpoints are correct? The ones written in the documnentation or the java bindings?
Thanks!
The JSON-wire-protocol is currently being adapted to support all the mobile actions. For now here is the documentation on how to do this.
Appium Gestures Documentation
May be this C# function that sends Fingerprint to Android emulator will help to someone.
fingerprintId = "1" - parameter that you need to configure in Android device in Settings.
string session_id = Program.Params.androidDriver.SessionId.ToString();
WebRequest request = WebRequest.Create("http://127.0.0.1:4723/wd/hub/session/" + session_id + "/appium/device/finger_print");
request.Method = "POST";
request.ContentType = "application/json;charset=UTF-8";
var my_jsondata = new
{
fingerprintId = "1"
};
var postData = JsonConvert.SerializeObject(my_jsondata);
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
Im setting up a project on a new dev machine. (Win7, vs2k12)
The code works fine on the production machine.
This code gives me "The operation has timed out".
var request = (HttpWebRequest) System.Net.WebRequest.Create(url);
request.Timeout = TimeoutMilliSeconds;
request.Method = "GET";
request.UserAgent = "X";
var response = (HttpWebResponse)request.GetResponse();
The url works fine when I call it from the browser.
I know which ports are open for incoming traffic.
Im using IIS express.
How do I proceed?
Thanks
Set the ReadWriteTimeout property.For details see a link:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.readwritetimeout.aspx
request.ReadWriteTimeout = 5000; //Increase Time as your requirement.
I ran into a weird problem while using openid in asp.net. I wanted a server side logout for gmail account but without redirecting to another page.
I thought executing a web request would do that. This is my code
HttpWebRequest loHttp =
(HttpWebRequest)WebRequest.Create("https://www.google.com/accounts/Logout");
// *** Set properties
loHttp.Timeout = 10000; // 10 secs
loHttp.UserAgent = "Code Sample Web Client";
// *** Retrieve request info headers
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();
Encoding enc = Encoding.GetEncoding(1252); // Windows default Code Page
StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream(), enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
But it doesn't seem to work. The gmail account is still signed in.
Is it possible to execute a webrequest with such URL?
Thanks
I think that's because HttpWebRequest is made at the server level and you are logged in in the client.
You should use an iframe to load the URL
In the application I am currently working on there is a backend java app that is caching a bunch of data. The asp.net part is allowing users to update database tables. Each time the DB is updated the cache in the java application should be cleared. So basically I have a list of 4 URLs that each need to be hit in order to clear the cache. My basic solution was to loop through each url and create a HttpWebRequest and get then get the response. So basically I have this for each request:
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentLength = 0;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
string responseString = readStream.ReadToEnd();
returnList.Add(string.Format("Refresh response from {0}.<br />{1}", url, responseString));
readStream.Close();
receiveStream.Close();
}
On my local machine everything works great. But when I deploy to our development server it just hangs and does nothing. If I remove request.ContentLength = 0; then the remote server throws a 411: Length expected error.
I am really stuck here and any help would be greatly appreciated.
Either a solution to the HttpWebRequest problem I am having or a different solution to calling each URL would work, I'm not picky.
Thanks in advance.
Why are using request.method as "POST"? Are you posting any data, if not try removing both content length and request method.
Pretty sure this was a network issue. I tried hitting a different url (the load balancer) and had no problems so the java guys are making a changes so I can just hit the load balancer and whatever server the request ends up on will make sure all servers caches are cleared.
The code that is working:
var request = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
string responseString = readStream.ReadToEnd();
returnString = string.Format(#"Refresh response from<br />{0}{1}", url, responseString);
readStream.Close();
receiveStream.Close();
}
I have a web service that I can only hit if I'm logged into the website that the web service is on. I need to test the service remotely. So I've written some code to create a fake session that is logged into the site in another browser. Then I made the HTTP Web Request and I'm attempting to set a cookie that contains the ASP.NET session ID of that logged in user. But the web service doesn't detect that the web request is a logged in user or session. What do I need to give the web service to convince it this is a valid session?
// used on each read operation
byte[] buf = new byte[8192];
CookieContainer myContainer = new CookieContainer();
string sessionID = SessionID;
myContainer.Add(new Cookie("ASP.NET_SessionId", sessionID, "/", WebsiteUrl));
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(CreateWebserviceUrl("doneScreenScore"));
request.ContentType = "text/xml; charset=utf-8";
request.Method = "POST";
request.Accept = "text/xml";
request.Headers.Add("SOAPAction", "http://detectent.net/doneScreenScore");
request.CookieContainer = myContainer;
Stream s = request.GetRequestStream();
string soaprequest = "";
soaprequest += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
soaprequest += "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">";
soaprequest += " <soap12:Body>";
soaprequest += " <doneScreenScore xmlns=\"http://detectent.net/\">";
soaprequest += " <input1>string</input1>";
soaprequest += "<input2>string</input2>";
soaprequest += "<input3>string</input3>";
soaprequest += "<input4>string</input4>";
soaprequest += "</doneScreenScore>";
soaprequest += "</soap12:Body>";
soaprequest += "</soap12:Envelope>";
s.Write(System.Text.Encoding.ASCII.GetBytes(soaprequest), 0, soaprequest.Length);
s.Close();
// execute the request
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
// we will read data via the response stream
Stream resStream = response.GetResponseStream();
string responseFromWebServiceCall = ReadResponseStream(resStream);
I think that you can do something with the credentials... I am doing this for a webservice...
rpt.Credentials = new System.Net.NetworkCredential(UserName, Password, Domain);
Without actually messing around with the thing myself I can't tell you exactly why it's not working. However I've done a bit of work writing applications which masquerade as a typical user for testing purposes and a tool I would recommend you familiarize yourself with is called WireShark. (Previously known as Ethereal)
WireShark is a packet sniffer. If you run it while browsing a website normally you will be able to see all the data being sent back and forth between your browser and the web server. Once you've found the information you need to make a request to this web service you should have no trouble constructing a proper WebRequest which behaves in the same manner.
You can download WireShark from the official site.
The NetworkCredentials work if the web site is using windows authentication.
I've had varying success impersonating a browser when doing this type of thing. Usually I have to make a valid request to their login page first. The response will contain a cookie with the SessionID. As long as I reuse the same CookieCollection for all the requests after that (ie. One global CookieCollection that is reused every request) it will work fine.
On the odd occasion, I still find that a website won't recognize my newly logged in session. In which case, I manually login with FireFox and use the WebDeveloper toolbar to view the cookies. I grab the cookie name/value and put them in the app settings, which is used by the program to populate the cookie collection.
Make sure you spoof a valid useragent too. I've had sites deny me because of that too.