mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-04 04:06:05 +13:00
Make sure ssl bypass dispose
This commit is contained in:
parent
355702cebd
commit
a7cc96b83b
4 changed files with 108 additions and 23 deletions
|
@ -1,4 +1,29 @@
|
||||||
using System;
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2007-2014 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
|
@ -1,4 +1,29 @@
|
||||||
using System;
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2007-2014 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
@ -1,4 +1,29 @@
|
||||||
using System;
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2007-2014 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
@ -72,30 +72,40 @@ public override UploadResult Upload(Stream stream, string fileName)
|
||||||
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
|
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
|
||||||
|
|
||||||
SSLBypassHelper sslBypassHelper = null;
|
SSLBypassHelper sslBypassHelper = null;
|
||||||
if (IgnoreInvalidCert)
|
|
||||||
sslBypassHelper = new SSLBypassHelper();
|
|
||||||
|
|
||||||
string response = SendRequestStream(url, stream, Helpers.GetMimeType(fileName), headers, method: HttpMethod.PUT);
|
try
|
||||||
|
|
||||||
UploadResult result = new UploadResult(response);
|
|
||||||
|
|
||||||
if (!IsError)
|
|
||||||
{
|
{
|
||||||
if (CreateShare)
|
if (IgnoreInvalidCert)
|
||||||
{
|
{
|
||||||
AllowReportProgress = false;
|
sslBypassHelper = new SSLBypassHelper();
|
||||||
result.URL = ShareFile(path);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
string response = SendRequestStream(url, stream, Helpers.GetMimeType(fileName), headers, method: HttpMethod.PUT);
|
||||||
|
|
||||||
|
UploadResult result = new UploadResult(response);
|
||||||
|
|
||||||
|
if (!IsError)
|
||||||
{
|
{
|
||||||
result.IsURLExpected = false;
|
if (CreateShare)
|
||||||
|
{
|
||||||
|
AllowReportProgress = false;
|
||||||
|
result.URL = ShareFile(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.IsURLExpected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (sslBypassHelper != null)
|
||||||
|
{
|
||||||
|
sslBypassHelper.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sslBypassHelper != null)
|
|
||||||
sslBypassHelper.Dispose();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://doc.owncloud.org/server/7.0/developer_manual/core/ocs-share-api.html#create-a-new-share
|
// http://doc.owncloud.org/server/7.0/developer_manual/core/ocs-share-api.html#create-a-new-share
|
||||||
|
|
Loading…
Reference in a new issue