Salut,
Pour l'instant je bloque sur
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
^-------- n'est pas déclaré...
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
Je ne connais pas l'espace de nom de config.url
C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir tester...
J'ai du ajouter les imports qui vont bien...
@+
LJ
"Patrice Manac'h" a écrit dans le message
de
news:Bonjour,
en utilisant un traducteur automatique et donc non testé...
Dim initBufferSize As Integer = 4000
Dim msgBuffer(initBufferSize) As Byte
Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
Dim bytesRead As Integer = 0
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
memStream.Position = 0
Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
Dim data As String = sr.ReadToEnd()
sr.Close()
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
EventLog.WriteEntry("HttpWO", "Data: " + data,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
EventLogEntryType.Information)
Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
HttpWebRequest)
oWRequest.Method = "POST"
oWRequest.ContentLength = postDataBytes.Length
If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0 Then
Dim myProxy As WebProxy = New WebProxy ()
myProxy = CType(oWRequest.Proxy, WebProxy)
EventLog.WriteEntry("HttpWO", "Current Proxy: " +
myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
config.ProxyPort)
EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
EventLogEntryType.Information)
myProxy.Address = newUri
oWRequest.Proxy = myProxy
End If
Dim oS1 As Stream = oWRequest.GetRequestStream()
oS1.Write(postDataBytes, 0, postDataBytes.Length)
oS1.Close()
Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
HttpWebResponse)
Dim oS As Stream = oWResponse.GetResponseStream()
Dim oSReader As StreamReader = New StreamReader (oS,
System.Text.Encoding.ASCII)
Dim txtResult As String = oSReader.ReadToEnd()
oSReader.Close()
oS.Close()
EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
EventLogEntryType.Information)
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
messagede news:
> Salut,
>
> Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
> dotnet...
> s)
>
> Je vais quand même essayer de le traduire... mais ça a l'air dur...
>
> @+
>
> LJ
> "Patrice Manac'h" a écrit dans le
message> de
> news:
>> Bonsoir,
>>
>> développer pour un contexte un peu particulier. Il vous faudra
> personnaliser
>> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> lecture
> d'un
>> stream) :
>> // retrieving stream content
>> int initBufferSize = 4000;
>> byte [] msgBuffer = new byte[initBufferSize];
>> MemoryStream memStream = new MemoryStream( initBufferSize );
>> int bytesRead = 0;
>> do
>> {
>> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> memStream.Write( msgBuffer, 0, bytesRead );
>> } while ( bytesRead == initBufferSize );
>>
>> memStream.Position = 0;
>>
>> StreamReader sr = new StreamReader( memStream, Encoding.UTF8 );
>> string data = sr.ReadToEnd();
>> sr.Close();
>> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>>
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information);
>>
>> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> config.URL );
>> oWRequest.Method = "POST";
>> oWRequest.ContentLength = postDataBytes.Length;
>>
>> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> 0 )
>> {
>> WebProxy myProxy=new WebProxy();
>> // Obtain the Proxy Prperty of the Default browser.
>> myProxy=(WebProxy)oWRequest.Proxy;
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>>
>> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> config.ProxyPort );
>>
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information);
>>
>> // Associate the new Uri object to the myProxy object.
>> myProxy.Address=newUri;
>>
>> // Create a NetworkCredential object and is assign to the
> Credentials
>> property of the Proxy object.
>> oWRequest.Proxy=myProxy;
>> }
>>
>> Stream oS1 = oWRequest.GetRequestStream();
>> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> oS1.Close();
>>
>> //la réponse (idem que pour un GET)
>> HttpWebResponse oWResponse =(HttpWebResponse)
> oWRequest.GetResponse();
>> Stream oS = oWResponse.GetResponseStream();
>> StreamReader oSReader = new
>> StreamReader(oS,System.Text.Encoding.ASCII);
>> string txtResult = oSReader.ReadToEnd();
>> oSReader.Close();
>> oS.Close();
>>
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information);
>>
>>
>>
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news: OHu%
>> > Salut @ tous,
>> >
>> > J'aurais besoin d'envoyer un formulaire en méthode post à partir du
>> > serveur
>> > web (pour éviter que l'internaute ne puisse voir le contenu de
certains>> > champs).
>> >
>> > Est-ce possible ?
>> >
>> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> > mémoire
>> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >
>> > D'avance merci
>> >
>> > @+
>> >
>> > Laurent
>> >
>> >
>>
>>
>
>
Salut,
Pour l'instant je bloque sur
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
^-------- n'est pas déclaré...
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
Je ne connais pas l'espace de nom de config.url
C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir tester...
J'ai du ajouter les imports qui vont bien...
@+
LJ
"Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le message
de
news:enWv0IPhEHA.2544@TK2MSFTNGP10.phx.gbl...
Bonjour,
en utilisant un traducteur automatique et donc non testé...
Dim initBufferSize As Integer = 4000
Dim msgBuffer(initBufferSize) As Byte
Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
Dim bytesRead As Integer = 0
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
memStream.Position = 0
Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
Dim data As String = sr.ReadToEnd()
sr.Close()
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
EventLog.WriteEntry("HttpWO", "Data: " + data,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
EventLogEntryType.Information)
Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
HttpWebRequest)
oWRequest.Method = "POST"
oWRequest.ContentLength = postDataBytes.Length
If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0 Then
Dim myProxy As WebProxy = New WebProxy ()
myProxy = CType(oWRequest.Proxy, WebProxy)
EventLog.WriteEntry("HttpWO", "Current Proxy: " +
myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
config.ProxyPort)
EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
EventLogEntryType.Information)
myProxy.Address = newUri
oWRequest.Proxy = myProxy
End If
Dim oS1 As Stream = oWRequest.GetRequestStream()
oS1.Write(postDataBytes, 0, postDataBytes.Length)
oS1.Close()
Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
HttpWebResponse)
Dim oS As Stream = oWResponse.GetResponseStream()
Dim oSReader As StreamReader = New StreamReader (oS,
System.Text.Encoding.ASCII)
Dim txtResult As String = oSReader.ReadToEnd()
oSReader.Close()
oS.Close()
EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
EventLogEntryType.Information)
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
message
de news: eEP5dNKhEHA.3664@TK2MSFTNGP12.phx.gbl...
> Salut,
>
> Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
> dotnet...
> s)
>
> Je vais quand même essayer de le traduire... mais ça a l'air dur...
>
> @+
>
> LJ
> "Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le
message
> de
> news:OrTAFNIhEHA.216@tk2msftngp13.phx.gbl...
>> Bonsoir,
>>
>> développer pour un contexte un peu particulier. Il vous faudra
> personnaliser
>> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> lecture
> d'un
>> stream) :
>> // retrieving stream content
>> int initBufferSize = 4000;
>> byte [] msgBuffer = new byte[initBufferSize];
>> MemoryStream memStream = new MemoryStream( initBufferSize );
>> int bytesRead = 0;
>> do
>> {
>> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> memStream.Write( msgBuffer, 0, bytesRead );
>> } while ( bytesRead == initBufferSize );
>>
>> memStream.Position = 0;
>>
>> StreamReader sr = new StreamReader( memStream, Encoding.UTF8 );
>> string data = sr.ReadToEnd();
>> sr.Close();
>> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>>
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information);
>>
>> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> config.URL );
>> oWRequest.Method = "POST";
>> oWRequest.ContentLength = postDataBytes.Length;
>>
>> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> 0 )
>> {
>> WebProxy myProxy=new WebProxy();
>> // Obtain the Proxy Prperty of the Default browser.
>> myProxy=(WebProxy)oWRequest.Proxy;
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>>
>> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> config.ProxyPort );
>>
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information);
>>
>> // Associate the new Uri object to the myProxy object.
>> myProxy.Address=newUri;
>>
>> // Create a NetworkCredential object and is assign to the
> Credentials
>> property of the Proxy object.
>> oWRequest.Proxy=myProxy;
>> }
>>
>> Stream oS1 = oWRequest.GetRequestStream();
>> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> oS1.Close();
>>
>> //la réponse (idem que pour un GET)
>> HttpWebResponse oWResponse =(HttpWebResponse)
> oWRequest.GetResponse();
>> Stream oS = oWResponse.GetResponseStream();
>> StreamReader oSReader = new
>> StreamReader(oS,System.Text.Encoding.ASCII);
>> string txtResult = oSReader.ReadToEnd();
>> oSReader.Close();
>> oS.Close();
>>
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information);
>>
>>
>>
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news: OHu%233rHhEHA.3992@TK2MSFTNGP11.phx.gbl...
>> > Salut @ tous,
>> >
>> > J'aurais besoin d'envoyer un formulaire en méthode post à partir du
>> > serveur
>> > web (pour éviter que l'internaute ne puisse voir le contenu de
certains
>> > champs).
>> >
>> > Est-ce possible ?
>> >
>> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> > mémoire
>> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >
>> > D'avance merci
>> >
>> > @+
>> >
>> > Laurent
>> >
>> >
>>
>>
>
>
Salut,
Pour l'instant je bloque sur
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
^-------- n'est pas déclaré...
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
Je ne connais pas l'espace de nom de config.url
C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir tester...
J'ai du ajouter les imports qui vont bien...
@+
LJ
"Patrice Manac'h" a écrit dans le message
de
news:Bonjour,
en utilisant un traducteur automatique et donc non testé...
Dim initBufferSize As Integer = 4000
Dim msgBuffer(initBufferSize) As Byte
Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
Dim bytesRead As Integer = 0
Do While
bytesRead = s.Read(msgBuffer, 0, initBufferSize)
memStream.Write(msgBuffer, 0, bytesRead)
LoopbytesRead = initBufferSize
memStream.Position = 0
Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
Dim data As String = sr.ReadToEnd()
sr.Close()
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
EventLog.WriteEntry("HttpWO", "Data: " + data,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
EventLogEntryType.Information)
Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
HttpWebRequest)
oWRequest.Method = "POST"
oWRequest.ContentLength = postDataBytes.Length
If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0 Then
Dim myProxy As WebProxy = New WebProxy ()
myProxy = CType(oWRequest.Proxy, WebProxy)
EventLog.WriteEntry("HttpWO", "Current Proxy: " +
myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
config.ProxyPort)
EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
EventLogEntryType.Information)
myProxy.Address = newUri
oWRequest.Proxy = myProxy
End If
Dim oS1 As Stream = oWRequest.GetRequestStream()
oS1.Write(postDataBytes, 0, postDataBytes.Length)
oS1.Close()
Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
HttpWebResponse)
Dim oS As Stream = oWResponse.GetResponseStream()
Dim oSReader As StreamReader = New StreamReader (oS,
System.Text.Encoding.ASCII)
Dim txtResult As String = oSReader.ReadToEnd()
oSReader.Close()
oS.Close()
EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
EventLogEntryType.Information)
EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
EventLogEntryType.Information)
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
messagede news:
> Salut,
>
> Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
> dotnet...
> s)
>
> Je vais quand même essayer de le traduire... mais ça a l'air dur...
>
> @+
>
> LJ
> "Patrice Manac'h" a écrit dans le
message> de
> news:
>> Bonsoir,
>>
>> développer pour un contexte un peu particulier. Il vous faudra
> personnaliser
>> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> lecture
> d'un
>> stream) :
>> // retrieving stream content
>> int initBufferSize = 4000;
>> byte [] msgBuffer = new byte[initBufferSize];
>> MemoryStream memStream = new MemoryStream( initBufferSize );
>> int bytesRead = 0;
>> do
>> {
>> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> memStream.Write( msgBuffer, 0, bytesRead );
>> } while ( bytesRead == initBufferSize );
>>
>> memStream.Position = 0;
>>
>> StreamReader sr = new StreamReader( memStream, Encoding.UTF8 );
>> string data = sr.ReadToEnd();
>> sr.Close();
>> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>>
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information);
>>
>> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> config.URL );
>> oWRequest.Method = "POST";
>> oWRequest.ContentLength = postDataBytes.Length;
>>
>> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> 0 )
>> {
>> WebProxy myProxy=new WebProxy();
>> // Obtain the Proxy Prperty of the Default browser.
>> myProxy=(WebProxy)oWRequest.Proxy;
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>>
>> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> config.ProxyPort );
>>
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information);
>>
>> // Associate the new Uri object to the myProxy object.
>> myProxy.Address=newUri;
>>
>> // Create a NetworkCredential object and is assign to the
> Credentials
>> property of the Proxy object.
>> oWRequest.Proxy=myProxy;
>> }
>>
>> Stream oS1 = oWRequest.GetRequestStream();
>> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> oS1.Close();
>>
>> //la réponse (idem que pour un GET)
>> HttpWebResponse oWResponse =(HttpWebResponse)
> oWRequest.GetResponse();
>> Stream oS = oWResponse.GetResponseStream();
>> StreamReader oSReader = new
>> StreamReader(oS,System.Text.Encoding.ASCII);
>> string txtResult = oSReader.ReadToEnd();
>> oSReader.Close();
>> oS.Close();
>>
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information);
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information);
>>
>>
>>
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news: OHu%
>> > Salut @ tous,
>> >
>> > J'aurais besoin d'envoyer un formulaire en méthode post à partir du
>> > serveur
>> > web (pour éviter que l'internaute ne puisse voir le contenu de
certains>> > champs).
>> >
>> > Est-ce possible ?
>> >
>> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> > mémoire
>> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >
>> > D'avance merci
>> >
>> > @+
>> >
>> > Laurent
>> >
>> >
>>
>>
>
>
Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait le
contenu du Stream dans la String data. Si vous construisez le corps de
POSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
avez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
de news:
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" a écrit dans le
> de
> news:
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news:
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" a écrit dans le
> message
>> > de
>> > news:
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
>> > message
>> >> de news: OHu%
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait le
contenu du Stream dans la String data. Si vous construisez le corps de
POSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
avez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
de news: eHo0UOchEHA.396@TK2MSFTNGP12.phx.gbl...
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le
> de
> news:enWv0IPhEHA.2544@TK2MSFTNGP10.phx.gbl...
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news: eEP5dNKhEHA.3664@TK2MSFTNGP12.phx.gbl...
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le
> message
>> > de
>> > news:OrTAFNIhEHA.216@tk2msftngp13.phx.gbl...
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
>> > message
>> >> de news: OHu%233rHhEHA.3992@TK2MSFTNGP11.phx.gbl...
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait le
contenu du Stream dans la String data. Si vous construisez le corps de
POSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
avez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
de news:
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" a écrit dans le
> de
> news:
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news:
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" a écrit dans le
> message
>> > de
>> > news:
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
>> > message
>> >> de news: OHu%
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Bonjour,
Merci de votre réponse.
Je crois que j'avais compris pour le data mais pas pour de s.read
data et s sont la même chaine ?
Mon idée est de construire le formulaire complet en laissant les valeurs
des
champs confidentiels vides. Lors du postback, je compte remplir les
valeurs
confidentielles et rediriger le tout vers le CGI de mon fournisseur de
SMS.
Il me reste donc 2 choses à faire.
Attribuer des valeurs aux items vides
Rediriger le post depuis le serveur vers le fournisseur de SMS.
Bien à vous
Laurent
"Patrice Manac'h" a écrit dans le message
de
news:Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait
le
contenu du Stream dans la String data. Si vous construisez le corps de
votrePOSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
vousavez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
messagede news:
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
tester...>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" a écrit dans le
message> de
> news:
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
Then>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news:
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" a écrit dans le
> message
>> > de
>> > news:
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
Encoding.UTF8 );>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
oWResponse.StatusCode,>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans
>> >> le
>> > message
>> >> de news: OHu%
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
du>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Bonjour,
Merci de votre réponse.
Je crois que j'avais compris pour le data mais pas pour de s.read
data et s sont la même chaine ?
Mon idée est de construire le formulaire complet en laissant les valeurs
des
champs confidentiels vides. Lors du postback, je compte remplir les
valeurs
confidentielles et rediriger le tout vers le CGI de mon fournisseur de
SMS.
Il me reste donc 2 choses à faire.
Attribuer des valeurs aux items vides
Rediriger le post depuis le serveur vers le fournisseur de SMS.
Bien à vous
Laurent
"Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le message
de
news:O1kWdgchEHA.2544@TK2MSFTNGP10.phx.gbl...
Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait
le
contenu du Stream dans la String data. Si vous construisez le corps de
votre
POSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
vous
avez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
message
de news: eHo0UOchEHA.396@TK2MSFTNGP12.phx.gbl...
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
tester...
>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le
message
> de
> news:enWv0IPhEHA.2544@TK2MSFTNGP10.phx.gbl...
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
Then
>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news: eEP5dNKhEHA.3664@TK2MSFTNGP12.phx.gbl...
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" <patmanac@online.microsoft.com> a écrit dans le
> message
>> > de
>> > news:OrTAFNIhEHA.216@tk2msftngp13.phx.gbl...
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
Encoding.UTF8 );
>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
oWResponse.StatusCode,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans
>> >> le
>> > message
>> >> de news: OHu%233rHhEHA.3992@TK2MSFTNGP11.phx.gbl...
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
du
>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>
Bonjour,
Merci de votre réponse.
Je crois que j'avais compris pour le data mais pas pour de s.read
data et s sont la même chaine ?
Mon idée est de construire le formulaire complet en laissant les valeurs
des
champs confidentiels vides. Lors du postback, je compte remplir les
valeurs
confidentielles et rediriger le tout vers le CGI de mon fournisseur de
SMS.
Il me reste donc 2 choses à faire.
Attribuer des valeurs aux items vides
Rediriger le post depuis le serveur vers le fournisseur de SMS.
Bien à vous
Laurent
"Patrice Manac'h" a écrit dans le message
de
news:Bonjour,
j'ai extrait ce code d'un programme qui récupérais un Stream et copiait
le
contenu du Stream dans la String data. Si vous construisez le corps de
votrePOSt "à la main", vous pouvez passer directement à la partie:
Dim data As String = "corps du POST"
Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
en faisant attention à l'encoding. J'ai utilisé UTF8 car c'est ce que me
demandait le site en face. Mais ce n'est peut être pas l'encoding dont
vousavez besoin...
Cordialement,
P. Manac'h
MCS France
"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
messagede news:
> Salut,
>
> Pour l'instant je bloque sur
>
> Do While
> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
> ^-------- n'est pas déclaré...
>
> memStream.Write(msgBuffer, 0, bytesRead)
> LoopbytesRead = initBufferSize
>
> Je ne connais pas l'espace de nom de config.url
>
> C'est tout ce qu je n'arrive pas à corriger... avant de pouvoir
tester...>
> J'ai du ajouter les imports qui vont bien...
>
> @+
>
> LJ
>
>
> "Patrice Manac'h" a écrit dans le
message> de
> news:
>> Bonjour,
>>
>> en utilisant un traducteur automatique et donc non testé...
>>
>> Dim initBufferSize As Integer = 4000
>> Dim msgBuffer(initBufferSize) As Byte
>> Dim memStream As MemoryStream = New MemoryStream (initBufferSize)
>> Dim bytesRead As Integer = 0
>> Do While
>> bytesRead = s.Read(msgBuffer, 0, initBufferSize)
>> memStream.Write(msgBuffer, 0, bytesRead)
>> LoopbytesRead = initBufferSize
>>
>> memStream.Position = 0
>>
>> Dim sr As StreamReader = New StreamReader (memStream, Encoding.UTF8)
>> Dim data As String = sr.ReadToEnd()
>> sr.Close()
>> Dim postDataBytes As Byte = Encoding.UTF8.GetBytes(data)
>> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> EventLogEntryType.Information)
>> Dim oWRequest As HttpWebRequest = CType(WebRequest.Create(config.URL),
>> HttpWebRequest)
>> oWRequest.Method = "POST"
>> oWRequest.ContentLength = postDataBytes.Length
>>
>> If config.ProxyServer.Length > 0 AndAlso config.ProxyPort.Length > 0
Then>> Dim myProxy As WebProxy = New WebProxy ()
>> myProxy = CType(oWRequest.Proxy, WebProxy)
>> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> myProxy.Address.AbsoluteUri, EventLogEntryType.Information)
>> Dim newUri As Uri = New Uri ("http://" + config.ProxyServer + ":" +
>> config.ProxyPort)
>> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> EventLogEntryType.Information)
>> myProxy.Address = newUri
>> oWRequest.Proxy = myProxy
>> End If
>>
>> Dim oS1 As Stream = oWRequest.GetRequestStream()
>> oS1.Write(postDataBytes, 0, postDataBytes.Length)
>> oS1.Close()
>> Dim oWResponse As HttpWebResponse = CType(oWRequest.GetResponse(),
>> HttpWebResponse)
>> Dim oS As Stream = oWResponse.GetResponseStream()
>> Dim oSReader As StreamReader = New StreamReader (oS,
>> System.Text.Encoding.ASCII)
>> Dim txtResult As String = oSReader.ReadToEnd()
>> oSReader.Close()
>> oS.Close()
>> EventLog.WriteEntry("HttpWO", "Satus: " + oWResponse.StatusCode,
>> EventLogEntryType.Information)
>> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> EventLogEntryType.Information)
>>
>> Cordialement,
>>
>> P. Manac'h
>> MCS France
>>
>> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le
> message
>> de news:
>> > Salut,
>> >
>> > Je sais que j'abuse, mais tu n'aurais pas le meme en vb ou vb
>> > dotnet...
>> > s)
>> >
>> > Je vais quand même essayer de le traduire... mais ça a l'air dur...
>> >
>> > @+
>> >
>> > LJ
>> > "Patrice Manac'h" a écrit dans le
> message
>> > de
>> > news:
>> >> Bonsoir,
>> >>
>> >> développer pour un contexte un peu particulier. Il vous faudra
>> > personnaliser
>> >> (l'utilisation d'UTF8 ou la création de la string plutôt que la
>> >> lecture
>> > d'un
>> >> stream) :
>> >> // retrieving stream content
>> >> int initBufferSize = 4000;
>> >> byte [] msgBuffer = new byte[initBufferSize];
>> >> MemoryStream memStream = new MemoryStream( initBufferSize );
>> >> int bytesRead = 0;
>> >> do
>> >> {
>> >> bytesRead = s.Read( msgBuffer, 0, initBufferSize );
>> >> memStream.Write( msgBuffer, 0, bytesRead );
>> >> } while ( bytesRead == initBufferSize );
>> >>
>> >> memStream.Position = 0;
>> >>
>> >> StreamReader sr = new StreamReader( memStream,
Encoding.UTF8 );>> >> string data = sr.ReadToEnd();
>> >> sr.Close();
>> >> byte[] postDataBytes = Encoding.UTF8.GetBytes( data );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Data: " + data,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "URL: " + config.URL,
>> >> EventLogEntryType.Information);
>> >>
>> >> HttpWebRequest oWRequest =(HttpWebRequest) WebRequest.Create(
>> >> config.URL );
>> >> oWRequest.Method = "POST";
>> >> oWRequest.ContentLength = postDataBytes.Length;
>> >>
>> >> if( config.ProxyServer.Length > 0 && config.ProxyPort.Length >
>> >> 0 )
>> >> {
>> >> WebProxy myProxy=new WebProxy();
>> >> // Obtain the Proxy Prperty of the Default browser.
>> >> myProxy=(WebProxy)oWRequest.Proxy;
>> >> EventLog.WriteEntry("HttpWO", "Current Proxy: " +
>> >> myProxy.Address.AbsoluteUri, EventLogEntryType.Information);
>> >>
>> >> Uri newUri=new Uri("http://" + config.ProxyServer + ":" +
>> >> config.ProxyPort );
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Proxy: " + config.ProxyServer,
>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Port: " + config.ProxyPort,
>> >> EventLogEntryType.Information);
>> >>
>> >> // Associate the new Uri object to the myProxy object.
>> >> myProxy.Address=newUri;
>> >>
>> >> // Create a NetworkCredential object and is assign to the
>> > Credentials
>> >> property of the Proxy object.
>> >> oWRequest.Proxy=myProxy;
>> >> }
>> >>
>> >> Stream oS1 = oWRequest.GetRequestStream();
>> >> oS1.Write( postDataBytes, 0, postDataBytes.Length );
>> >> oS1.Close();
>> >>
>> >> //la réponse (idem que pour un GET)
>> >> HttpWebResponse oWResponse =(HttpWebResponse)
>> > oWRequest.GetResponse();
>> >> Stream oS = oWResponse.GetResponseStream();
>> >> StreamReader oSReader = new
>> >> StreamReader(oS,System.Text.Encoding.ASCII);
>> >> string txtResult = oSReader.ReadToEnd();
>> >> oSReader.Close();
>> >> oS.Close();
>> >>
>> >> EventLog.WriteEntry("HttpWO", "Satus: " +
oWResponse.StatusCode,>> >> EventLogEntryType.Information);
>> >> EventLog.WriteEntry("HttpWO", "Response: " + txtResult,
>> >> EventLogEntryType.Information);
>> >>
>> >>
>> >>
>> >>
>> >> "Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans
>> >> le
>> > message
>> >> de news: OHu%
>> >> > Salut @ tous,
>> >> >
>> >> > J'aurais besoin d'envoyer un formulaire en méthode post à partir
du>> >> > serveur
>> >> > web (pour éviter que l'internaute ne puisse voir le contenu de
> certains
>> >> > champs).
>> >> >
>> >> > Est-ce possible ?
>> >> >
>> >> > Je ne vois pas comment fabriquer le formulaire et son contenu en
>> >> > mémoire
>> >> > mais j'ai le présentiment qu'il doit-y avoir une solution...
>> >> >
>> >> > D'avance merci
>> >> >
>> >> > @+
>> >> >
>> >> > Laurent
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>