/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public void process(IOSHttpRequest request, IOSHttpResponse response, byte[] data) { m_timeout.Stop(); m_httpListener.RemoveSimpleStreamHandler(m_uploaderPath); m_timeout.Dispose(); if (!request.RemoteIPEndPoint.Address.Equals(m_remoteAddress)) { response.StatusCode = (int)HttpStatusCode.Unauthorized; return; } if (OnUpLoad == null) { response.StatusCode = (int)HttpStatusCode.Gone; return; } if (!BunchOfCaps.ValidateAssetData((byte)AssetType.LSLText, data)) { response.StatusCode = (int)HttpStatusCode.BadRequest; return; } response.StatusCode = (int)HttpStatusCode.OK; try { string res = String.Empty; LLSDTaskScriptUploadComplete uploadComplete = new LLSDTaskScriptUploadComplete(); ArrayList errors = new ArrayList(); OnUpLoad?.Invoke(m_inventoryItemID, m_primID, m_isScriptRunning, m_experienceKey, data, ref errors); uploadComplete.new_asset = m_inventoryItemID; uploadComplete.compiled = errors.Count > 0 ? false : true; uploadComplete.state = "complete"; uploadComplete.errors = new OpenSim.Framework.Capabilities.OSDArray(); uploadComplete.errors.Array = errors; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); if (m_dumpAssetToFile) { Util.SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); } // m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); response.RawBuffer = Util.UTF8NBGetbytes(res); } catch { LLSDAssetUploadError error = new LLSDAssetUploadError(); error.message = "could not compile script"; error.identifier = UUID.Zero; response.RawBuffer = Util.UTF8NBGetbytes(LLSDHelpers.SerialiseLLSDReply(error)); return; } }
/// <summary> /// Handle raw uploaded asset data. /// </summary> /// <param name="data"></param> /// <param name="path"></param> /// <param name="param"></param> /// <returns></returns> public void process(IOSHttpRequest request, IOSHttpResponse response, byte[] data) { m_timeout.Stop(); m_httpListener.RemoveSimpleStreamHandler(m_uploaderPath); m_timeout.Dispose(); if (!request.RemoteIPEndPoint.Address.Equals(m_remoteAdress)) { response.StatusCode = (int)HttpStatusCode.Unauthorized; return; } string res = String.Empty; if (OnUpLoad == null) { response.StatusCode = (int)HttpStatusCode.Gone; return; } if (!BunchOfCaps.ValidateAssetData(m_assetType, data)) { response.StatusCode = (int)HttpStatusCode.BadRequest; return; } UUID assetID = OnUpLoad(m_inventoryItemID, m_objectID, data); if (assetID == UUID.Zero) { LLSDAssetUploadError uperror = new LLSDAssetUploadError(); uperror.message = "Failed to update inventory item asset"; uperror.identifier = m_inventoryItemID; res = LLSDHelpers.SerialiseLLSDReply(uperror); } else { LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = assetID.ToString(); uploadComplete.new_inventory_item = m_inventoryItemID; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); } if (m_dumpAssetToFile) { Util.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } response.StatusCode = (int)HttpStatusCode.OK; response.RawBuffer = Util.UTF8NBGetbytes(res); }