OVH Cloud OVH Cloud

Post à partir du serveur.

13 réponses
Avatar
Laurent Jordi \(www.ezlogic.mc\)
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

10 réponses

1 2
Avatar
Patrice Manac'h
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




Avatar
Laurent Jordi \(www.ezlogic.mc\)
Merci beaucoup

J'espère que je serais à la hauteur de la modification...

Bien à toi

Laurent
"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
>
>




Avatar
Laurent Jordi \(www.ezlogic.mc\)
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
>
>




Avatar
Patrice Manac'h
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
>
>








Avatar
Laurent Jordi \(www.ezlogic.mc\)
Salut,

J'aimerais bien savoir ou tu l'as trouvé ?

@+

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
>> >
>> >
>>
>>
>
>




Avatar
Laurent Jordi \(www.ezlogic.mc\)
reSalut,

En tout cas merci... :)

A charge de revenche....

@+

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
>> >
>> >
>>
>>
>
>




Avatar
Patrice Manac'h
Bonsoir,

http://www.developerfusion.com/utilities/convertcsharptovb.aspx

Cordialement,

P. Manac'h
MCS France

"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le message
de news: %
Salut,

J'aimerais bien savoir ou tu l'as trouvé ?

@+

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
>> >
>> >
>>
>>
>
>








Avatar
Patrice Manac'h
Bonsoir,

et cela marche ?

Cordialement,

P. Manac'h
MCS France

"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le message
de news:
reSalut,

En tout cas merci... :)

A charge de revenche....

@+

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
>> >
>> >
>>
>>
>
>








Avatar
Laurent Jordi \(www.ezlogic.mc\)
G pas encore eu le temps...

Aujourd'hui ct journée commerciale...

@+

Je te tiendrais au jus

"Patrice Manac'h" a écrit dans le message de
news:
Bonsoir,

et cela marche ?

Cordialement,

P. Manac'h
MCS France

"Laurent Jordi (www.ezlogic.mc)" <inf[o]@ezlogic.mc> a écrit dans le


message
de news:
> reSalut,
>
> En tout cas merci... :)
>
> A charge de revenche....
>
> @+
>
> 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
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>




Avatar
Laurent Jordi \(www.ezlogic.mc\)
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
>> >
>> >
>>
>>
>
>




1 2