Luke Briggs

Web requester redesigned to workaround removal of things in u2017

......@@ -73,9 +73,6 @@ namespace PowerUI{
}
void Update(){
// Update HTTP services:
Web.Flush();
RefreshTimer++;
if(Status==2){
......
......@@ -129,11 +129,6 @@ namespace PowerUI{
}
public void OnInspectorUpdate(){
// Update HTTP services:
Web.Flush();
}
void OnGUI(){
if(AvailableTargets==null){
......
......@@ -88,11 +88,12 @@ namespace PowerUI{
}
/// <summary>Got data is called by the file handler when the response is received.</summary>
/// <param name="data">The data that was recieved, if any.</param>
/// <param name="status">The HTTP status code.</param>
public override void ReceivedData(byte[] data,int offset,int count){
this.responseBytes=data;
base.ReceivedData(data,offset,count);
public override void ReceivedData(byte[] buffer,int offset,int count){
ReceiveAllData(buffer, offset, count);
}
public override void ReceivedAllData(byte[] buffer){
this.responseBytes=buffer;
}
}
......@@ -181,8 +182,17 @@ namespace PowerUI{
private Headers responseHeaders_;
/// <summary>An internal abortable object.</summary>
internal IAbortable abortableObject;
/// <summary>The method to use.</summary>
public string requestMethod=null;
/// <summary>True if the content should always be interpreted as a video.</summary>
public virtual bool ForceVideo{
get{
return false;
}
}
/// <summary>The headers to send with this request. They're lowercase. Status line is indexed as the empty string.</summary>
public Headers requestHeaders{
get{
......@@ -449,7 +459,6 @@ namespace PowerUI{
/// <summary>All headers are ready. Returns true if we're redirecting.</summary>
internal bool ReceivedHeaders(){
if(LoadStatusAndLength()){
// Redirecting.
return true;
......@@ -457,7 +466,6 @@ namespace PowerUI{
readyState=2;
return false;
}
/// <summary>All headers are ready.</summary>
......@@ -602,6 +610,42 @@ namespace PowerUI{
}
private System.IO.MemoryStream _stream;
/// <summary>Use this to combine all the data into one buffer.
/// Call it from RecieveData and override ReceivedAllData to get that single result.</summary>
public void ReceiveAllData(byte[] buffer, int offset, int count){
if(readyState_==1){
// No headers received; trigger it anyway:
ReceivedHeaders();
}
if(_stream == null){
_stream = new System.IO.MemoryStream();
}
bytesReceived+=count;
_stream.Write(buffer, offset, count);
if(bytesReceived>=contentLength){
// Received all of the data!
byte[] data = _stream.ToArray();
_stream = null;
Callback.MainThread(delegate(){
ReceivedAllData(data);
readyState=4;
});
}else{
readyState=3;
}
}
public virtual void ReceivedAllData(byte[] buffer){
}
#if !MOBILE && !UNITY_WEBGL
internal virtual void ReceivedMovieTexture(UnityEngine.MovieTexture tex){
......
......@@ -199,19 +199,14 @@ namespace PowerUI{
/// <summary>Called by the file handler when the contents are available.</summary>
public override void ReceivedData(byte[] buffer,int offset,int count){
if(Contents.LoadData(buffer,this)){
// Base:
base.ReceivedData(buffer,offset,count);
}else{
ReceiveAllData(buffer, offset, count);
}
public override void ReceivedAllData(byte[] buffer){
if(!Contents.LoadData(buffer, this)){
// Failed:
Failed(500);
}
}
/// <summary>Called when this image is going to be displayed.</summary>
......
......@@ -799,9 +799,6 @@ public static class UI{
// Update animations:
Spa.SPA.Update(deltaTime);
// Update any Http requests:
Web.Update(deltaTime);
if(WorldUI.LiveUpdatablesAvailable){
WorldUI.UpdateAll();
}
......@@ -819,6 +816,9 @@ public static class UI{
return;
}
// Check for timeouts:
Web.Update(frameTime);
// Atlases:
AtlasStacks.Update();
......
Subproject commit 7be65dfea24f969b833533527f04994faf27892f
Subproject commit fa4363dcb40aa11bc95329cb17c4dd2dd14def0d
......
......@@ -35,8 +35,6 @@ namespace PowerUI{
/// <summary>The host document.</summary>
private HtmlDocument HostDocument;
/// <summary>The method to use.</summary>
private string Method="get";
/// <summary>Creates a request relative to the given document.</summary>
......@@ -44,6 +42,7 @@ namespace PowerUI{
// Apply document:
HostDocument=document;
requestMethod="get";
}
......@@ -80,9 +79,9 @@ namespace PowerUI{
}
Method=method.Trim().ToLower();
requestMethod=method.Trim().ToLower();
if(Method=="get" || Method=="post"){
if(requestMethod=="get" || requestMethod=="post"){
// Apply the path:
location=new Location(
......@@ -120,7 +119,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(byte[] data){
if(Method=="post"){
if(requestMethod=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -136,7 +135,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(JSObject data){
if(Method=="post"){
if(requestMethod=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -152,7 +151,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(HtmlDocument data){
if(Method=="post"){
if(requestMethod=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -168,7 +167,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(string data){
if(Method=="post"){
if(requestMethod=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -225,7 +224,7 @@ namespace PowerUI{
/// <summary>Send this request.</summary>
public override void send(){
if(Method=="post"){
if(requestMethod=="post"){
request=new byte[0];
}
......