I’m trying to request a file via WWW with caching turned off,
but I’m getting an error:
It seems useful that we may want to turn off browser caching for certain files.
Here’s how I got the error.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
string url = "http://path/to/my/file";
WWW m_www = null;
public TextAsset m_body = null;
// Use this for initialization
void Start () {
Hashtable headers = new Hashtable();
headers["Pragma"] = "no-cache";
headers["Expires"] = "-1";
headers["Cache-Control"] = "no-store,no-cache,must-revalidate";
m_www = new WWW(url, m_body.bytes, headers);
}
// Update is called once per frame
void Update () {
if (null != m_www
m_www.isDone)
{
Debug.Log(string.Format("Found {0} bytes", m_www.bytes.Length));
m_www = null;
}
}
you need to use POST instead of GET
Your sample is kind of strange anyway as you pass nothing at all actually.
You mean it’s an empty request. Meh it didn’t work anyway.
I’m going to just put a GUID as a url param, that should be easy enough.
Right, thats what I meant.
As an empty request, it can’t be a POST, post requires at least 1 parameter unless I remember wrong.
That parameter normally would be the file you want to get, so I’m not understanding why you even have such a request less WWW sample.
Okay I modified the example. The body will come from a text asset in the project.
And it will say GET /path/to/file HTTP/1.1
etc etc
The point of this post is to just show using custom headers throws an error.