Luke Briggs

Further changes to HTTP for Unity 2017

Subproject commit a9acfd1ca247f676cc9cb48c099d88154b145926
Subproject commit 817ab0e65b885db50f2b942bf211b3763caabd80
......
......@@ -88,12 +88,11 @@ namespace PowerUI{
}
/// <summary>Got data is called by the file handler when the response is received.</summary>
public override void ReceivedData(byte[] buffer,int offset,int count){
ReceiveAllData(buffer, offset, count);
}
public override void ReceivedAllData(byte[] buffer){
this.responseBytes=buffer;
/// <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);
}
}
......@@ -182,17 +181,8 @@ 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{
......@@ -459,6 +449,7 @@ namespace PowerUI{
/// <summary>All headers are ready. Returns true if we're redirecting.</summary>
internal bool ReceivedHeaders(){
if(LoadStatusAndLength()){
// Redirecting.
return true;
......@@ -466,6 +457,7 @@ namespace PowerUI{
readyState=2;
return false;
}
/// <summary>All headers are ready.</summary>
......@@ -610,42 +602,6 @@ 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,14 +199,19 @@ namespace PowerUI{
/// <summary>Called by the file handler when the contents are available.</summary>
public override void ReceivedData(byte[] buffer,int offset,int count){
ReceiveAllData(buffer, offset, count);
}
public override void ReceivedAllData(byte[] buffer){
if(!Contents.LoadData(buffer, this)){
if(Contents.LoadData(buffer,this)){
// Base:
base.ReceivedData(buffer,offset,count);
}else{
// Failed:
Failed(500);
}
}
/// <summary>Called when this image is going to be displayed.</summary>
......
Subproject commit fa4363dcb40aa11bc95329cb17c4dd2dd14def0d
Subproject commit 6d1843fb2db20d9115b6a924e0ce5a52294bf3ea
......
......@@ -35,6 +35,8 @@ 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>
......@@ -42,7 +44,6 @@ namespace PowerUI{
// Apply document:
HostDocument=document;
requestMethod="get";
}
......@@ -79,9 +80,9 @@ namespace PowerUI{
}
requestMethod=method.Trim().ToLower();
Method=method.Trim().ToLower();
if(requestMethod=="get" || requestMethod=="post"){
if(Method=="get" || Method=="post"){
// Apply the path:
location=new Location(
......@@ -119,7 +120,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(byte[] data){
if(requestMethod=="post"){
if(Method=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -135,7 +136,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(JSObject data){
if(requestMethod=="post"){
if(Method=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -151,7 +152,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(HtmlDocument data){
if(requestMethod=="post"){
if(Method=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -167,7 +168,7 @@ namespace PowerUI{
/// <summary>Send this request with the given post data.</summary>
public void send(string data){
if(requestMethod=="post"){
if(Method=="post"){
if(data==null){
request=new byte[0];
}else{
......@@ -224,7 +225,7 @@ namespace PowerUI{
/// <summary>Send this request.</summary>
public override void send(){
if(requestMethod=="post"){
if(Method=="post"){
request=new byte[0];
}
......