Click here to Skip to main content
15,895,799 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sin(pi) isn't always zero Pin
Luc Pattyn14-Dec-08 8:04
sitebuilderLuc Pattyn14-Dec-08 8:04 
AnswerRe: Sin(pi) = 3,23108510433268E-15 Pin
Paul Conrad14-Dec-08 9:10
professionalPaul Conrad14-Dec-08 9:10 
GeneralRe: Sin(pi) = 3,23108510433268E-15 Pin
Luc Pattyn14-Dec-08 9:36
sitebuilderLuc Pattyn14-Dec-08 9:36 
GeneralRe: Sin(pi) = 3,23108510433268E-15 Pin
Paul Conrad14-Dec-08 11:01
professionalPaul Conrad14-Dec-08 11:01 
GeneralRe: Sin(pi) = 3,23108510433268E-15 Pin
Christian Graus14-Dec-08 9:36
protectorChristian Graus14-Dec-08 9:36 
GeneralRe: Sin(pi) = 3,23108510433268E-15 Pin
Mark Salsbery14-Dec-08 10:52
Mark Salsbery14-Dec-08 10:52 
GeneralRe: Sin(pi) = 3,23108510433268E-15 Pin
Paul Conrad14-Dec-08 11:03
professionalPaul Conrad14-Dec-08 11:03 
QuestionCan't sand ae HTTP POST request with HttpWebRequest Pin
Raphael Javaux14-Dec-08 7:14
Raphael Javaux14-Dec-08 7:14 
Hello,
I'm trying to make a HTTP POST request in multipart/form-data to simulate the upload of a file to a web server.
But I've a problem, the class only send Headers and don't send data.

My query is like this :
[root@localhost rapha]# python server.py
IP :  ('127.0.0.1', 32851)
POST / HTTP/1.1
User-Agent: FilesApi/FilesAPI v0.1 (Unix 2.6.27.7)
Referer: [url]http://api.files.getwebb.org[/url]
Content-Type: multipart/form-data; boundary=-------------------906641065
Content-Length: 1845
Expect: 100-continue
Connection: keep-alive
Host: 127.0.0.1

But normaly, it will be like this :
[root@localhost rapha]# python server.py
IP :  ('127.0.0.1', 32851)
POST / HTTP/1.1
User-Agent: FilesApi/FilesAPI v0.1 (Unix 2.6.27.7)
Referer: [url]http://api.files.getwebb.org[/url]
Content-Type: multipart/form-data; boundary=-------------------906641065
Content-Length: 1845
Expect: 100-continue
Connection: keep-alive
Host: 127.0.0.1

-------------------906641065
Content-Disposition: form-data; name="fichier1"; filename="icon.png"
Content-Type: application/octet-stream

[I](contenu de l'image)[/I]
---------------------906641065Content-Disposition: form-data; name="nb_fichiers"

1
---------------------906641065
Content-Disposition: form-data; name="votes"

on
---------------------906641065--


My sources :
string Boundary = "-------------------" + (new System.Random()).Next(); // Séparateur des éléments du formulaire
			
string Data = Boundary + "\r\n";
			
// Création de la requête pour les fichiers
int FichierNo = 0;
foreach(string Fichier in this.FilesList) {
	FichierNo++;
			
	System.IO.FileInfo FileInfos = new System.IO.FileInfo(Fichier);
				
	Data += "Content-Disposition: form-data; name=\"fichier" + FichierNo + "\"; filename=\"" + FileInfos.Name + "\"\r\n"; // Nom du fichier
              Data += "Content-Type: application/octet-stream\r\n\r\n"; // Mimetype 
				
	Data += (new System.IO.StreamReader(Fichier)).ReadToEnd()+ "\r\n"; // Ajout du contenu du fichier
	Data += "--" + Boundary; // Fin de l'enregistrement
}

// Nombre de fichiers
Data += "Content-Disposition: form-data; name=\"nb_fichiers\"\r\n\r\n";
Data += FichierNo + "\r\n";
Data += "--" + Boundary;
			
// Activer le vote
if(this.EnableVotes) {
	Data += "\r\nContent-Disposition: form-data; name=\"votes\"\r\n\r\n";
	Data += "on\r\n";
	Data += "--" + Boundary;
}
			
// Envoyer par email
if(this.Email != null) {
              Data += "\r\nContent-Disposition: form-data; name=\"check_email\"\r\n\r\n";
	Data += "on\r\n";
	Data += "--" + Boundary + "\r\n";
				
	Data += "Content-Disposition: form-data; name=\"email\"\r\n\r\n";
	Data += this.Email + "\r\n";
	Data += "--" + Boundary;
}
			
// Fin de requete
Data += "--\r\n";
			
byte[] DataBytes = (new System.Text.ASCIIEncoding()).GetBytes(Data);

// Envoi de la requete			
System.Net.HttpWebRequest Request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create("http://127.0.0.1/");
Request.Method = "POST";
Request.UserAgent = this.Agent;
Request.Referer = "http://api.files.getwebb.org";
				
Request.ContentType = "multipart/form-data; boundary=" + Boundary;
Request.ContentLength = DataBytes.Length;
			
// Envoi des données
System.IO.Stream PostData = Request.GetRequestStream();
PostData.Write(DataBytes, 0, DataBytes.Length);
PostData.Close();


I've the same problem with the code from the MSDN : http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.method(VS.80).aspx

I've tried with Mono and with .NET, but nothing change.


Note : To intercept data, I've make a Python server who listen on the port 80, but with Fiddler, a HTTP debug proxy, I don't see data too.
Thanks
AnswerRe: Can't sand ae HTTP POST request with HttpWebRequest Pin
Garth J Lancaster14-Dec-08 11:03
professionalGarth J Lancaster14-Dec-08 11:03 
QuestionPropertyGrid change font of Values Pin
Xmen Real 14-Dec-08 6:33
professional Xmen Real 14-Dec-08 6:33 
AnswerRe: PropertyGrid change font of Values Pin
netJP12L14-Dec-08 13:13
netJP12L14-Dec-08 13:13 
GeneralRe: PropertyGrid change font of Values Pin
Xmen Real 14-Dec-08 14:38
professional Xmen Real 14-Dec-08 14:38 
Questionsaving DataTable in Properties.Settings Pin
Xmen Real 14-Dec-08 6:31
professional Xmen Real 14-Dec-08 6:31 
AnswerRe: saving DataTable in Properties.Settings Pin
Christian Graus14-Dec-08 9:37
protectorChristian Graus14-Dec-08 9:37 
GeneralRe: saving DataTable in Properties.Settings Pin
Xmen Real 14-Dec-08 14:40
professional Xmen Real 14-Dec-08 14:40 
QuestionHow to capture video file on screen? Pin
ping_jacob14-Dec-08 6:16
ping_jacob14-Dec-08 6:16 
AnswerRe: How to capture video file on screen? Pin
Xmen Real 14-Dec-08 6:37
professional Xmen Real 14-Dec-08 6:37 
QuestionControls Overlapping Pin
Silvyster14-Dec-08 2:29
Silvyster14-Dec-08 2:29 
AnswerRe: Controls Overlapping Pin
Colin Angus Mackay14-Dec-08 4:42
Colin Angus Mackay14-Dec-08 4:42 
QuestionDesigner Crashes IDE Pin
#realJSOP14-Dec-08 2:11
mve#realJSOP14-Dec-08 2:11 
AnswerRe: Designer Crashes IDE Pin
Giorgi Dalakishvili14-Dec-08 2:26
mentorGiorgi Dalakishvili14-Dec-08 2:26 
GeneralRe: Designer Crashes IDE Pin
#realJSOP14-Dec-08 5:52
mve#realJSOP14-Dec-08 5:52 
GeneralRe: Designer Crashes IDE Pin
Giorgi Dalakishvili14-Dec-08 5:57
mentorGiorgi Dalakishvili14-Dec-08 5:57 
AnswerRe: Designer Crashes IDE Pin
Christian Graus14-Dec-08 9:38
protectorChristian Graus14-Dec-08 9:38 
GeneralRe: Designer Crashes IDE Pin
#realJSOP14-Dec-08 11:27
mve#realJSOP14-Dec-08 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.