mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +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.Drawing;
|
||||
using System.Linq;
|
||||
|
@ -64,4 +89,4 @@ public static ContextMenuStrip Create<TEntry>(TextBox tb, params TEntry[] ignore
|
|||
return cms;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.Linq;
|
||||
using System.Text;
|
||||
|
@ -20,4 +45,4 @@ public CodeMenuEntry(string value, string description)
|
|||
|
||||
public abstract string ToPrefixString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.Linq;
|
||||
using System.Text;
|
||||
|
@ -17,4 +42,4 @@ public ExtCodeMenuEntry(string value, string description) : base(value, descript
|
|||
public static readonly ExtCodeMenuEntry png = new ExtCodeMenuEntry("png", "Portable Network Graphic");
|
||||
public static readonly ExtCodeMenuEntry tif = new ExtCodeMenuEntry("tif", "Tagged Image File");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -72,30 +72,40 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
|
||||
|
||||
SSLBypassHelper sslBypassHelper = null;
|
||||
if (IgnoreInvalidCert)
|
||||
sslBypassHelper = new SSLBypassHelper();
|
||||
|
||||
string response = SendRequestStream(url, stream, Helpers.GetMimeType(fileName), headers, method: HttpMethod.PUT);
|
||||
|
||||
UploadResult result = new UploadResult(response);
|
||||
|
||||
if (!IsError)
|
||||
try
|
||||
{
|
||||
if (CreateShare)
|
||||
if (IgnoreInvalidCert)
|
||||
{
|
||||
AllowReportProgress = false;
|
||||
result.URL = ShareFile(path);
|
||||
sslBypassHelper = new SSLBypassHelper();
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue