зеркало из https://github.com/mono/mail-archives.git
284 строки
8.8 KiB
HTML
284 строки
8.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-bugs] [Bug 478451] New: WebClient.UploadData throws "ProtocolViolationException" on FTP upload
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20478451%5D%20New%3A%20WebClient.UploadData%20throws%0A%20%22ProtocolViolationException%22%20on%20FTP%20upload&In-Reply-To=">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="086346.html">
|
|
<LINK REL="Next" HREF="086357.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-bugs] [Bug 478451] New: WebClient.UploadData throws "ProtocolViolationException" on FTP upload</H1>
|
|
<B>bugzilla_noreply at novell.com</B>
|
|
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20478451%5D%20New%3A%20WebClient.UploadData%20throws%0A%20%22ProtocolViolationException%22%20on%20FTP%20upload&In-Reply-To="
|
|
TITLE="[Mono-bugs] [Bug 478451] New: WebClient.UploadData throws "ProtocolViolationException" on FTP upload">bugzilla_noreply at novell.com
|
|
</A><BR>
|
|
<I>Sat Feb 21 05:46:57 EST 2009</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="086346.html">[Mono-bugs] [Bug 373757] zero lenght file installed: /usr/lib/mono/2.0/xbuild.rsp
|
|
</A></li>
|
|
<LI>Next message: <A HREF="086357.html">[Mono-bugs] [Bug 478451] WebClient.UploadData throws "ProtocolViolationException" on FTP upload
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#86347">[ date ]</a>
|
|
<a href="thread.html#86347">[ thread ]</a>
|
|
<a href="subject.html#86347">[ subject ]</a>
|
|
<a href="author.html#86347">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE><A HREF="https://bugzilla.novell.com/show_bug.cgi?id=478451">https://bugzilla.novell.com/show_bug.cgi?id=478451</A>
|
|
|
|
|
|
Summary: WebClient.UploadData throws
|
|
"ProtocolViolationException" on FTP upload
|
|
Classification: Mono
|
|
Product: Mono: Class Libraries
|
|
Version: SVN
|
|
Platform: 32bit
|
|
OS/Version: Ubuntu
|
|
Status: NEW
|
|
Severity: Normal
|
|
Priority: P5 - None
|
|
Component: System
|
|
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
|
|
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">martijndijksterhuis at gmail.com</A>
|
|
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
|
|
Found By: ---
|
|
|
|
|
|
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5)
|
|
Gecko/2008121622 Ubuntu/8.10 (intrepid) Firefox/3.0.5
|
|
|
|
Trying to upload an FTP file through the WebClient class results in an
|
|
exception:
|
|
|
|
[System.Net.ProtocolViolationException: Operation is not valid due to the
|
|
current state of the object at System.Net.FtpWebRequest.BeginGetRequestStream
|
|
(System.AsyncCallback callback, System.Object state) [0x00000]]
|
|
|
|
I have tried the code included below on Mono SVN (fails), Mono 1.9.1 (fails)
|
|
and Visual C# studio 2008 (succeeds)
|
|
|
|
|
|
|
|
|
|
|
|
Reproducible: Always
|
|
|
|
Steps to Reproduce:
|
|
1.Use the code below to upload a file
|
|
2.Watch it fail with the above exception
|
|
Actual Results:
|
|
System.Net.WebException: An error occurred performing a WebClient request. --->
|
|
System.Net.ProtocolViolationException: Operation is not valid due to the
|
|
current state of the object
|
|
at System.Net.FtpWebRequest.BeginGetRequestStream (System.AsyncCallback
|
|
callback, System.Object state) [0x00000]
|
|
at System.Net.FtpWebRequest.GetRequestStream () [0x00000]
|
|
at System.Net.WebClient.UploadDataCore (System.Uri address, System.String
|
|
method, System.Byte[] data, System.Object userToken) [0x00000]
|
|
at System.Net.WebClient.UploadData (System.Uri address, System.String method,
|
|
System.Byte[] data) [0x00000] --- End of inner exception stack trace ---
|
|
|
|
at System.Net.WebClient.UploadData (System.Uri address, System.String method,
|
|
System.Byte[] data) [0x00000]
|
|
at System.Net.WebClient.UploadData (System.Uri address, System.Byte[] data)
|
|
[0x00000]
|
|
at (wrapper remoting-invoke-with-check) System.Net.WebClient:UploadData
|
|
(System.Uri,byte[])
|
|
at BasicFTPClientNamespace.BasicFTPClient.UploadData (System.String path,
|
|
System.Byte[] Data) [0x0001d] in
|
|
/home/nis/martijn/Projects/BasicFTP/BasicFTP/Main.cs:83
|
|
at BasicFTPClientNamespace.BasicFTPClient.UploadFile (System.String ftppath,
|
|
System.String srcfile) [0x00056] in
|
|
/home/nis/martijn/Projects/BasicFTP/BasicFTP/Main.cs:109
|
|
at BasicFTPClientNamespace.MainClass.Main (System.String[] args) [0x0002f] in
|
|
/home/nis/martijn/Projects/BasicFTP/BasicFTP/Main.cs:127
|
|
|
|
|
|
Expected Results:
|
|
Successful upload of the file to the FTP server.
|
|
|
|
// Main.cs created with MonoDevelop
|
|
// User: martijn at 4:39 PM 2/18/2009
|
|
//
|
|
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
|
|
//
|
|
using System;
|
|
using System.Net;
|
|
using System.IO;
|
|
|
|
namespace BasicFTPClientNamespace
|
|
{
|
|
class BasicFTPClient
|
|
{
|
|
public string Username;
|
|
public string Password;
|
|
public string Host;
|
|
public int Port;
|
|
|
|
public BasicFTPClient()
|
|
{
|
|
Username = "anonymous";
|
|
Password = "<A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">anonymous at internet.com</A>";
|
|
Port = 21;
|
|
Host = "";
|
|
}
|
|
|
|
public BasicFTPClient(string theUser,string thePassword,string theHost)
|
|
{
|
|
Username = theUser;
|
|
Password = thePassword;
|
|
Host = theHost;
|
|
Port = 21;
|
|
}
|
|
|
|
private Uri BuildServerUri(string Path)
|
|
{
|
|
return new Uri(String.Format("<A HREF="ftp://{0}:{1}/{2}",Host,Port,Path">ftp://{0}:{1}/{2}",Host,Port,Path</A>));
|
|
}
|
|
|
|
|
|
public byte[] UploadData(string path,byte[] Data)
|
|
{
|
|
// Get the object used to communicate with the server.
|
|
WebClient request = new WebClient();
|
|
|
|
// Logon to the server using username + password
|
|
request.Credentials = new NetworkCredential (Username,Password);
|
|
return request.UploadData(BuildServerUri(path),Data);
|
|
}
|
|
|
|
public byte[] UploadFile(string ftppath,string srcfile)
|
|
{
|
|
// Read the data from disk
|
|
FileStream fs = new FileStream(srcfile, FileMode.Open);
|
|
byte [] FileData = new byte[fs.Length];
|
|
|
|
int numBytesToRead = (int)fs.Length;
|
|
int numBytesRead = 0;
|
|
while (numBytesToRead > 0)
|
|
{
|
|
// Read may return anything from 0 to numBytesToRead.
|
|
int n = fs.Read(FileData, numBytesRead, numBytesToRead);
|
|
|
|
// Break when the end of the file is reached.
|
|
if (n == 0) break;
|
|
|
|
numBytesRead += n;
|
|
numBytesToRead -= n;
|
|
}
|
|
numBytesToRead = FileData.Length;
|
|
fs.Close();
|
|
|
|
// Upload the data from the buffer
|
|
return UploadData(ftppath,FileData);
|
|
}
|
|
|
|
}
|
|
|
|
class MainClass
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
BasicFTPClient MyClient = new BasicFTPClient();
|
|
|
|
MyClient.Host="myserver";
|
|
MyClient.Port=21;
|
|
MyClient.Username="myusername";
|
|
MyClient.Password="mypassword";
|
|
|
|
try
|
|
{
|
|
MyClient.UploadFile("upload.test","/tmp/output.txt");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e.ToString());
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
--
|
|
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
|
|
------- You are receiving this mail because: -------
|
|
You are the QA contact for the bug.
|
|
You are the assignee for the bug.
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="086346.html">[Mono-bugs] [Bug 373757] zero lenght file installed: /usr/lib/mono/2.0/xbuild.rsp
|
|
</A></li>
|
|
<LI>Next message: <A HREF="086357.html">[Mono-bugs] [Bug 478451] WebClient.UploadData throws "ProtocolViolationException" on FTP upload
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#86347">[ date ]</a>
|
|
<a href="thread.html#86347">[ thread ]</a>
|
|
<a href="subject.html#86347">[ subject ]</a>
|
|
<a href="author.html#86347">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
|
|
mailing list</a><br>
|
|
</body></html>
|