You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by da...@gmx.net on 2006/11/01 12:22:22 UTC

looking for the request OutputStream

Hello,

I am new in network programming.


The following example shows, how I handle the inputstream
with HttpClient.

//********************************************************

//...
        client = new HttpClient();
        
        initHttpsProtocol();
        initHost();

        GetMethod  method = new GetMethod(SERVERURL);
        
        try {
            int statusCode = client.executeMethod(method);

//          ...  exception handling

            // I am looking for the opposite
            InputStream in = method.getResponseBodyAsStream();
            DataInputStream dataIn = new DataInputStream(in);
            String test = dataIn.readUTF();
            
             // make a flush ...
             // close and handle the response

...
//********************************************************

I am looking for the opposite.

How can the client make an outpustream and send data to
the server ?


The data I want to transport are some :

    'Strings' to control the workflow and
    'files'   (context-type : application/octet-stream)


I found nothing about OutpuStreams, only something like :

    method.setQueryString(NameValuePair[] arg0);

Probably I am on the wrong way,

thanks for help,

Bastian
-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: looking for the request OutputStream

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2006-11-06 at 12:41 +0100, dasKleineb@gmx.net wrote:
> Thanks for your help.
> 
> How can I handle the RequestEntity stream on the server ?
> Should I implement a ResponseEntity class or is there
> a way to read the stream for example with readUTF()?
> 
> basti
> 

Basti

It very much depends what kind of software you are running on the
server. Are you using a servlet engine to process HTTP requests? 

Oleg

> 
> > On Wed, 2006-11-01 at 12:22 +0100, dasKleineb@gmx.net wrote:
> > > Hello,
> > > 
> > > I am new in network programming.
> > > 
> > > 
> > > The following example shows, how I handle the inputstream
> > > with HttpClient.
> > > 
> > > //********************************************************
> > > 
> > > //...
> > >         client = new HttpClient();
> > >         
> > >         initHttpsProtocol();
> > >         initHost();
> > > 
> > >         GetMethod  method = new GetMethod(SERVERURL);
> > >         
> > >         try {
> > >             int statusCode = client.executeMethod(method);
> > > 
> > > //          ...  exception handling
> > > 
> > >             // I am looking for the opposite
> > >             InputStream in = method.getResponseBodyAsStream();
> > >             DataInputStream dataIn = new DataInputStream(in);
> > >             String test = dataIn.readUTF();
> > >             
> > >              // make a flush ...
> > >              // close and handle the response
> > > 
> > > ...
> > > //********************************************************
> > > 
> > > I am looking for the opposite.
> > > 
> > > How can the client make an outpustream and send data to
> > > the server ?
> > > 
> > 
> > Bastian,
> > 
> > Use one of the RequestEntity implementations shipped with HttpClient or
> > implement a custom one.
> > 
> > http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/RequestEntity.java
> > 
> > You can take this piece of code as a starting point if you end up
> > needing a custom RequestEntity
> > 
> > http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java
> > 
> > Oleg
> > 
> > > 
> > > The data I want to transport are some :
> > > 
> > >     'Strings' to control the workflow and
> > >     'files'   (context-type : application/octet-stream)
> > > 
> > > 
> > > I found nothing about OutpuStreams, only something like :
> > > 
> > >     method.setQueryString(NameValuePair[] arg0);
> > > 
> > > Probably I am on the wrong way,
> > > 
> > > thanks for help,
> > > 
> > > Bastian
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: looking for the request OutputStream

Posted by da...@gmx.net.
Thanks for your help.

How can I handle the RequestEntity stream on the server ?
Should I implement a ResponseEntity class or is there
a way to read the stream for example with readUTF()?

basti


> On Wed, 2006-11-01 at 12:22 +0100, dasKleineb@gmx.net wrote:
> > Hello,
> > 
> > I am new in network programming.
> > 
> > 
> > The following example shows, how I handle the inputstream
> > with HttpClient.
> > 
> > //********************************************************
> > 
> > //...
> >         client = new HttpClient();
> >         
> >         initHttpsProtocol();
> >         initHost();
> > 
> >         GetMethod  method = new GetMethod(SERVERURL);
> >         
> >         try {
> >             int statusCode = client.executeMethod(method);
> > 
> > //          ...  exception handling
> > 
> >             // I am looking for the opposite
> >             InputStream in = method.getResponseBodyAsStream();
> >             DataInputStream dataIn = new DataInputStream(in);
> >             String test = dataIn.readUTF();
> >             
> >              // make a flush ...
> >              // close and handle the response
> > 
> > ...
> > //********************************************************
> > 
> > I am looking for the opposite.
> > 
> > How can the client make an outpustream and send data to
> > the server ?
> > 
> 
> Bastian,
> 
> Use one of the RequestEntity implementations shipped with HttpClient or
> implement a custom one.
> 
> http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/RequestEntity.java
> 
> You can take this piece of code as a starting point if you end up
> needing a custom RequestEntity
> 
> http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java
> 
> Oleg
> 
> > 
> > The data I want to transport are some :
> > 
> >     'Strings' to control the workflow and
> >     'files'   (context-type : application/octet-stream)
> > 
> > 
> > I found nothing about OutpuStreams, only something like :
> > 
> >     method.setQueryString(NameValuePair[] arg0);
> > 
> > Probably I am on the wrong way,
> > 
> > thanks for help,
> > 
> > Bastian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: looking for the request OutputStream

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2006-11-01 at 12:22 +0100, dasKleineb@gmx.net wrote:
> Hello,
> 
> I am new in network programming.
> 
> 
> The following example shows, how I handle the inputstream
> with HttpClient.
> 
> //********************************************************
> 
> //...
>         client = new HttpClient();
>         
>         initHttpsProtocol();
>         initHost();
> 
>         GetMethod  method = new GetMethod(SERVERURL);
>         
>         try {
>             int statusCode = client.executeMethod(method);
> 
> //          ...  exception handling
> 
>             // I am looking for the opposite
>             InputStream in = method.getResponseBodyAsStream();
>             DataInputStream dataIn = new DataInputStream(in);
>             String test = dataIn.readUTF();
>             
>              // make a flush ...
>              // close and handle the response
> 
> ...
> //********************************************************
> 
> I am looking for the opposite.
> 
> How can the client make an outpustream and send data to
> the server ?
> 

Bastian,

Use one of the RequestEntity implementations shipped with HttpClient or
implement a custom one.

http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/RequestEntity.java

You can take this piece of code as a starting point if you end up
needing a custom RequestEntity

http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/methods/FileRequestEntity.java

Oleg

> 
> The data I want to transport are some :
> 
>     'Strings' to control the workflow and
>     'files'   (context-type : application/octet-stream)
> 
> 
> I found nothing about OutpuStreams, only something like :
> 
>     method.setQueryString(NameValuePair[] arg0);
> 
> Probably I am on the wrong way,
> 
> thanks for help,
> 
> Bastian


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org