how to disable caching HTTP GET in metro app, I am using IXMLHTTPRequest2 - microsoft-metro

I am doing an http GET to fetch data, I am using IXMLHTTPRequest2.
If I GET url "http://foo.com" (curl "http://foo.com"), the second time I get this url again, the content on server is actually changed, but what I am getting is the cached result.
Caching seems only honor URL, so if different header with same URL, still same cached result.
I have tried "Cache-Control: no-cache", "Cache Control: no-store", and "Pragma: no-cache". None of them are honored by the API.
Is there a way to turn cache off or walk around? (One walk around I am using is appending garbage at end of URL but I am not feeling good with it).

my question got answered here by Prashant: http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/1df95d3e-68c9-4351-822a-c2cfde380248/#1df95d3e-68c9-4351-822a-c2cfde380248
You can force XHR to retrieve the latest content by setting the "If-Modified-Since" HTTP header in the request and set a time in the past.
If you have control over the server response, you could send back an Expires HTTP response header with a value 0 or a date in the past. That should make XHR retrieve the latest response for you.
You are only required to do one of the above, changing both the client and server side code is not necessary.
The client side code could be changed to something like this:
xhr->Open(...)
xhr->SetRequestHeader(L"If-Modified-Since", L"Sat, 01 Jan 2000 00:00:01 GMT");
xhr->Send(...)
For changing the server side behavior if your server side code is based on ASP.net you could change your response header like this:
Response.Headers.Add("Expires", "0")

I think you need to use sockets.....i think these two links should help
C# WebClient disable cache
How do I Create an HTTP Request Manually in .Net?

Related

Webextension: Set response headers for web_accessible_resources

To provide some custom caching via a webextension, I use web_accessible_resources and redirect accesses towards them in a background script – see my previous question for details.
While that works content wise, I cannot find a way to change the response headers of the cached content, for example the Last-Modified header. So when I cache content that the original website does some consistence checks on, this will fail.
I tried to intercept the redirected response with an onHeadersReceived handler, but this never triggers as “Only requests made using HTTP or HTTPS will trigger events” and my redirect uses the moz-extension:// protocol.
How does one set response headers when serving web_accessible_resources?
Is it possible at all?

Is it possible to change/modify properties of a CR using OSLC_CM?

Is it possible to modify a property of a change request by using the OSLC-CM REST API of a change management system. The system that I'm trying to achieve that is Rational Change.
I can browse and query via the REST API, but to modify anything I need to resort to command line which is rather slow.
Is there a way?
BR,
Pawel
To update resources using the OSLC-CM REST API you simply just can use HTTP PUT. In order to do this, you'll first need the URL of the Change Request.
The steps to achieve this (using any HTTP client) are:
acquire URL for Change Request (usually done by query, or stored reference, etc)
Perform an HTTP GET on that URL, specifying a format for use in editing. This is done using 'Accept' header, some typical values would be 'application/xml', 'application/json' or 'application/rdf+xml'.
Note, it is a good idea to set the header 'OSLC-Core-Verson: 2.0' as well to ensure you are working with the 2.0 formats.
Once you have fetched the resource, modify the property to the value you want.
Using HTTP PUT, send the modified resource in the content body to the same URL you fetched the resource from.
Additionally you will most likely need to pass along some additional headers to help the server detect any possible conflict.
You should get back a 200 (OK) or 204 (No content) response on success.
An optimization would be to do the same steps as above but only request the properties of interest and only send them by using the selective properties feature of OSLC.
So I've finally got it working with some help from googlegroups
To recap what I've done so that someone else might benefit too (I really have searched for it and the IBM documentation is as in most of the cases not helping):
So to modify PR/CR' implement_actual_effort attribute on the Rational Change server the following procedure was successful (using Firefox REST plugin):
1. In Headers set: Accept to application/xml, Content-Type to application/xml
Put the oslc address of the cr i URL in my case it was:
http://[IP:PORT]/change/oslc/db/[DB hex ID]/role/User/cr/[web_encoded_name_of_the_CR]?oslc_cm.properties=change:implement_actual_effort
(note in browser http://[IP:PORT]/change/oslc/db/[DB hex ID]/role/User/cr/[web_encoded_name_of_the_CR] will open change page of the CR/PR)
In REST client set Method to GET and press SEND
Click on the Response Body (RAW), copy xml Body
Change Method to PUT, change the value of the attribute (in the xml in Body window)
Press SEND
Attribute should have been changed right now, and the response should be similiar to what you've sent, with the attribute showing the change.
Note that to change an attribute (called property from oslc point of view) one has to provide ?oslc_cm.properties=[properties delimited with comma]
and in the request body xml the same properties have to be present, if I remember correctly if the property isn't mentioned in the xml it will be set to default
I hope this helps someone
BR,
Pawel

500 read timeout Selenium : on opening website with large records

I am using Perl with Selenium. I have set $sel->set_timeout("86400000");.
When opening a website with large content, 500 read timeout message is displayed. Can someone please help me?
It seems to me that not the Selenium webdriver (the client) has issued the timeout, but the webserver has been waiting too long.
What do you want to accomplish? Maybe you can just make a HTTP HEAD request to check that your URL is valid? (A HEAD request does not give you any content back, just the HTTP header with the http status code and, optionally, the "Content-Length" header, among other fields. The HEAD request is much faster that a GET or POST request and yo won't have problems with timeouts. You might get more than one HEAD respnses e.g. if your request is redirected to another server.
Or do you want to check the large content itself. Then I cannot help you at this point. There is not enough information.
You can use a Test::WWW::Mechanize object to create the HEAD request (it is a subclass of LWP::Request). NOt sure if selenium supports head requests.

How Do I Upload Multiple Files Using the iPhone

I am posting (HTTP POST) various values to the posterous api. I am successfully able to upload the title, body, and ONE media file, but when I try to add in a second media file I get a server 500.
They do allow media and media[] as parameters.
How do I upload multiple files with the iPhone SDK?
The 500 your getting is probably based on one of two things:
An incorrect request
An error on the server
Now, if its an incorrect, the HTTP server would be more helpful responding back with like a 415 (unsupported media type) or something. A 500 insists that something went wrong on the server and that your request was valid.
You'll have to dig into the server API or code (if you wrote it), or read the docs and figure out what's wrong with your second request ... seems like maybe your not setting the appropriate media type?
EDIT: Ok, so I looked at the API. It appears your posting XML, so your request content-type should be
Content-Type: application/xml
The API doc didn't specifically say, but that would be the correct type.
EDIT: Actually on second glance, are you just POSTing w/URI params? Their API doc isn't clear (I'm also looking rather quickly)

Prevent an HTTP client from hitting a server with cache (iphone)

Ok, I'm confused. I'm trying to send back the magic headers from my server that will prevent a client from hitting the server again until a resource is stale.
I understand how ETag or Last-Modified works (Validation) - the client will ALWAYS still hit the server, and the server needs to validate the date or etag against the current value to know whether to bother serving up a new one.
Cache-Control and Expires, however, I don't think I understand. I've set the following:
Cache-Control: max-age=86400, must-revalidate
No matter what I do, my client (my browser, curl, NSURLConnection) always hits the server again on the second request. Is this a client thing? What headers should I send back to get the client to use it's private cache for a certain length of time?
As Nathan hints at in his answer, clients can issue a subsequent request with an If-Modified-Since header to determine whether or not their cache is stale. If the client receives a 304 Not Modified response, it will serve the content out of the local cache.
According to RFC 2616 (the HTTP 1.1 specification), the presence of must-revalidate within the Cache-control header forces clients to re-check their cache's status with the originating server prior to serving out of the cache.
For future reference - Mark Nottingham has written a great guide to HTTP caching:
http://www.mnot.net/cache_docs/#CACHE-CONTROL
The server needs to check the If-Modified-Since header and return a 304 not modified header if it wants the browser to keep caching.