Redirect coldfusion page after a timeout - coldfusion

Can I set a particular coldfusion page to redirect after a certain amount of execution time?
It runs a process that can take a long time, but I want to allow it 60 seconds to attempt it then direct it to a new page that will indicate how much of the operation was completed.

Not exactly sure what you are after here but another thought might be to flush the available output to the user as it is processing. ColdFusion has a tag for this to make it easy.
See the docs regarding the cfflush tag.
It can send back information at a specific interval that you define.
interval (Optional)
Integer. Flushes output each time this number of bytes becomes available. HTML headers, and data that is already available when the tag is executed, are omitted from the count.

Something real simple would be to use a META refresh.
<meta http-equiv="refresh" content="60;url=http://yoursite.com/somepage.cfm">
Or, you could use Javascript:
setTimeout(function(){ location.href="http://yoursite.com/somepage.cfm" }, 60000);

Related

libcurl C++: which parameters to listen to when checking if a webpage has been updated?

I've recently been using libcurl to detect when a particular web page has been updated by listening for a change in the page's HTTPS status code by employing CURLINFO_RESPONSE_CODE.
However, I am attempting to retrieve newly uploaded data from a different webpage now, but its HTTPS status code stays the same at 200 even when the page has been updated with new information.
As such, are there any other parameters that can be monitored to notify as quickly as possible that there has been a change in the content of a page? Initially, I thought about counting the number of bytes in the page when it's returned via my libcurl function, and then checking if the next response's byte length is different (hence, signalling that some new content has been added to the page).
This is a time-sensitive application however, and this method of counting the number of bytes and making a comparison for every request-response may not be the best approach in terms of latency, and also may not be particularly accurate (e.g. maybe an aspect in the header such as a "hit/miss from cloudfront" could result in a different page length size, even though there isn't any new front-end content uploaded).
Summary question:
Are there any parameters (perhaps in the response header?) other than the HTTPS status code that can be monitored with libcurl to check if a page has been updated with any new content, as quickly as possible?

REST API - Update of single resource changes multiple others

I'm looking for a way how to deal with a following problem:
Imagine you modify a resource and that subsequently causes update of other resources.
E.g. you issue a PUT to, say /api/orders/1234, which by definition changes state of all other Orders of given user. There may be UI clients that display the table of Orders and they should know that not only single item in the table was updated, but eventually other as well.
Now, is there any standard way how inform a clients about such a situation?
So far I can only think of sending back the 205 Reset Content HTTP status code to inform the client that he should refresh the state, as not just a single thing was changed.
There are multiple solutions.
You can define specific resources as non-cacheable, so the client does not cache them at all. (no-store)
You can try giving a max-age of 0, so the client will have to re-validate those resources always. In this case you might have to implement ETags and conditional GETs, but it will be easier on the server than option 1.
Some push method like WebSockets.
If you really want to "notify" potentially multiple clients of a change, then it sounds like you would need option 3.
However, correctly configured caching is normally good enough. For example you could mark not-yet-executed orders as not cached (max-age=0), but as soon as it is executed, you might mark it to be cached indefinitely, since it can not change anymore.

Sharing data across Sitecore pipelines

I´m trying to perform some actions in the pipeline "httpRequestBegin" only when necessary.
My processor is executed after Sitecore resolves the user (processor type="Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel" ), as i´m resolving the user too if Sitecore is not able to resolve it first.
Later, i want to add some rendering in the pipeline "insertRenderings", only if actions in the previous pipeline were executed (If i resolved the user, show a message), so i´m trying to save some "flag" in the first step, to check in the second.
My question is, where can I store that flag? I´m trying to find some kind of "per request" cache...
So far, I've tried:
The session: Wrong, it's too early, session doesn't exists yet.
Items (HttpContext.Current.Items): It doesn't work either, my item is not there on the seconds step.
So far i'm using the application cache (HttpContext.Current.Cache) with some unique key, but I don´t like this solution.
Anybody body knows a better approach to share this "flag"?
You could add a flag to the request header and then check it's existence in the latter pipelines, e.g.
// in HttpRequest pipeline
HttpContext.Current.Request.Headers.Add("CustomUserResolve", "true");
// in InsertRenderings pipeline
var customUserResolve = HttpContext.Current.Request.Headers["CustomUserResolve"];
if (Sitecore.MainUtil.GetBool(customUserResolve, false))
{
// custom logic goes here
}
This feels a little dirty, I think adding to Request.QueryString or Request.Params would been nicer but those are readonly. However, if you only need this for a one time deal (i.e. only the first time it is resolved) then it will work since in the next request the Headers are back to default without your custom header added.
HttpContext.Current.Cache or HttpRuntime.Cache could be the fastest solution here. Though this approach would not preserve data when the AppPool gets recycled.
If you add only a few keys to the cache and then maintain them, this solution might work for you. If each request puts an entry into the cache, it may eventually overflow the memory used by worker process in a long run.
As alternative to this you may try to use Sitecore.Context.ClientData property. It uses ClientDataStore that employs a database (look for clientDataStore section in the web.config file) to store data. These entries can survive the AppPool recycle.
Though if you use them a lot, it may become a bottleneck under the load when you need to write to and/or read from the entries.
If you do know that there could be a lot of entries created for sharing purposes, I'd create a scheduled task to clean up the data store from obsolete entries.
I know this is a very old question, but I just want post solution I worked around
Below will hold data per http request basis.
HttpContext.Current.Items["ModuleInfo"] = "Custom Module Info"
we can store data to httpcontext in one sitecore pipeline and retrieve in another...
https://www.codeproject.com/Articles/146455/When-Can-We-Use-HttpContext-Current-Items-to-Store

Is there a limit to the number of form fields you can submit?

I have a rather long form (1000 checkboxes) that the customer goes through to order.
But I get the following error when it goes over a certain limit (100 items):
Failed to add HTML header.ColdFusion was unable to add the header you
specified to the output stream. This is probably because you have
already used a cfflush tag in your template or buffered output is
turned off
Q: Is that an IIS setting or a ColdFusion administrator setting?
I did some research before posting this question, and it doesn't have to do with AJAX and debug settings. All debug settings are turned off and I get the error on form submit.
Does your form POST or GET? If it's a GET you may be maxing out the URL length limit. If it's a POST, then you are probably running into the limit in CF on the number of form fields. This article details how to modify the value.
You may want to consider other ways of sending that data to the server. Perhaps using jQuery to serialise the form and send the JSON as a single parameter?
Sounds very similar to an error we had after moving a site with a large number of fields to a new environment. our error read a bit different but you could be getting a different error depending on what you're doing.
500
ROOT CAUSE:
coldfusion.filter.FormScope$PostParametersLimitExceededException: POST
parameters exceeds the maximum limit specified in the server.
There is a coldfusion setting in your runtime.xml file you could try changing or removing:
<var name='postParametersLimit'><number>100.0</number></var>

Two distinct responses from RESTful web service for a single call

How can I get 2 or multiple responses back from a CXF based RESTFul webservice for a single call.
For example : For this http://localhost:8080/report/annual, I would like to get 2 JSON reponses back. The first one will give me the information about the report details & some other information. The second reponse will give me the actual report JSON. If these 2 be delivered async that will be really good.
I'm with #flesk, this really isn't a REST approach, this is more of an async messaging approach.
The first call should return "someinfo" after it starts the "actualReport" processing (in a separate thread/process since "actualReport" is time consuming). Then make a second call for "actualReport" and make sure the timeout value on that call is set high enough to let the report processing complete.
You could get fancy and loop on the second call, returning a 404 until the report is complete.
There are a number of ways to get what you want, just not with one RESTful call.
You can't. Why would you want to do that anyway, when you can just return something like
{"someInfo": {...}, "actualReport": {...}}