Retrieving HTTP status code from a loaded xul:browser tag - xul

Thanks to everyone in advance -
I took a look at this -
An observer for page loads in a custom xul:browser
I am guessing that might be a path for determining the HTTP status code, but does anyone know of an easier way? I have flipped through the contentDocument as well...no dice.
Any ideas?
Thanks,
Sam

I looked for a bit and I don't think there is an easier way. The HTTP status code is an attribute of a request (and only of an HTTP request), so it appears to die with the request object (nsIHttpChannel), since nothing cares to save it.
You might be interested in this Firefox project, by the way: https://wiki.mozilla.org/Firefox/Projects/Network_Error_Pages

Related

Request URI too long on spartacus services

I've been trying to make use of service.getNavigation() method, but apparently the Request URI is too long which causes this error:
Request-URI Too Long
The requested URL's length exceeds the capacity limit for this server.
Is there a spartacus config that can resolve this issue?
Or is this supposed to be handled in the cloud (ccv2) config?
Not sure which service are you talking about specifically and what data are you passing there. For starters, please read this: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414
Additionally it would benefit everyone if you could say something about the service you're using and the data you are trying to pass/get.
The navigation component is firing a request for all componentIds. If you have a navigation with a lot of (root?) elements, the maximum length of HTTP GET request might be too long for the given client or server.
The initial implementation of loading components was actually done by a POST request, but the impression was that we would not need to support requests with so many components. I guess we were wrong.
Luckily, the legacy POST based request is still in the code base, it's OccCmsComponentAdapter.findComponentsByIdsLegacy.
The easiest way for you to use this code, is to provide a CustomOccCmsComponentAdapter, that extends from OccCmsComponentAdapter. Then you can override the findComponentsByIds method and simply call the super.findComponentsByIdsLegacy and pass in a copy of the arguments.
A more cleaner way would be to override the CmsComponentConnector and directly delegate the load to the adapter.findComponentsByIdsLegacy. I would not start here, as it's more complicated. Do a POC with the first suggested approach.

WCF methods are getting called twice when their HTTP verb is PUT or DELETE

I have a WCF service with multiple endpoints which I call from AJAX/JS. Everything is working fine, except if I go to my log table.
I store every call to this wcf service in a table and I've noticed that, if the verb used to call the methods is PUT or DELETE, the method is called twice. Of course, it has no impact on data since PUT and DELETE are supposed to be idempotent (and I made the corresponding stored procedures to act as such).
Digging this problem, I have changed PUT to POST in one method and it was then only called once. Changed it back to PUT, and it was called twice again. So it can't be related to the DataContracts, as I have read in another post. I have used SVCTraceViewer and nothing unexpected appeared, except for the double calls of course.
I must also add that
1) WebDav Publishing is NOT installed
2) I've checked in IIS and svc handlers have all verbs authorized
Still, I'm more and more convinced it's a IIS issue, but I don't know where to look.
Any advice would be welcome.
Thanks for the time you've spent reading this post... and thinking of an solution to my problem.
OK, found it. Thought I would post the answer : I was using Response status code 204 for put and delete successful requests. However it seems that code 204 asks the page to remain and actually request the same url a second time. Changed it to 202 : problem solved.
Best regards to stack o.

RESTful way of getting a resource, but creating it if it doesn't exist yet

For a RESTful API that I'm creating, I need to have some functionality that get's a resource, but if it doesn't exist, creates it and then returns it. I don't think this should be the default behaviour of a GET request. I could enable this functionality on a certain parameter I give to the GET request, but it seems a little bit dirty.
The main point is that I want to do only one request for this, as these requests are gonna be done from mobile devices that potentially have a slow internet connection, so I want to limit the requests that need to be done as much as possible.
I'm not sure if this fits in the RESTful world, but if it doesn't, it will disappoint me, because it will mean I have to make a little hack on the REST idea.
Does anyone know of a RESTful way of doing this, or otherwise, a beatiful way that doesn't conflict with the REST idea?
Does the client need to provide any information as part of the creation? If so then you really need to separate out GET and POSTas otherwise you need to send that information with each GET and that will be very ugly.
If instead you are sending a GET without any additional information then there's no reason why the backend can't create the resource if it doesn't already exist prior to returning it. Depending on the amount of time it takes to create the resource you might want to think about going asynchronous and using 202 as per other answers, but that then means that your client has to handle (yet) another response code so it might be better off just waiting for the resource to be finalised and returned.
very simple:
Request: HEAD, examine response code: either 404 or 200. If you need the body, use GET.
It not available, perform a PUT or POST, the server should respond with 204 and the Location header with the URL of the newly created resource.

Need Http Request not to respond until it finds a specific text in Jmeter

I have searched for the solution to my problem throughout the web, but couldn't find any.
I need jmeter not to throw a response of an HTTP Request until it founds an specific text in response, because I have this request which takes so much time to respond and generate an specific text, but http request responds back immediately hence not find that specific text.
How to do it? should I use some kind of logic controller, which one and how?
As I am new to Jmeter so I need a proper guidance and solution to this problem.
If what you want is wait for a page change that will display the expected text, then this might be the answer otherwise try to clarify:
http://www.sourcepole.ch/2011/1/4/waiting-for-a-page-change-in-jmeter

ASIHTTPRequest Disabling Cache

I have an application which logs into an online site using POST form being sent from ASIHTTPRequest & ASIFormDataRequest.
I have a log in box, a .xib where user enters their details. Then as they click OK, it connects to the site with the details user has entered. It sends the form OK etc.
But there is a problem. I enter the incorrect details first, it connects and tells me the html of response. I can tell from the html that the details are incorrect. Now i enter the correct details, and ASI* does not even bother connecting.
When I enter the correct details first, it tells me a different html which is supposed to show whenever I enter the right log in details.
So the problem is in cache, because it doesn't bother connecting again on second request, right?
I am using Little Snitch.app, so i know when it connects, and when it does not.
Now, the question sounds: "How do I disable Cache in ASIRequests?"
Thanks a lot.
Snippet of class: http://pastebin.com/a83YCpnm
ASIHTTPRequest doesn't cache POST responses by default - see the following code in ASIHTTPRequest.m
if (![[self requestMethod] isEqualToString:#"GET"]) {
[self setDownloadCache:nil];
}
There's clearly something else going on - are you sure it's a POST request you're making? How are you enabling caching / creating the request, can you post some code please?
Alright I found out what the trouble was. I did not reallocate the ASIFormDataRequest & ASIHTTPRequest on each request, which was causing the trouble on other requests because it was being reused.
Therefore the request has been marked as complete and so it did not even bother making another request if that makes sense.
Thanks