Hope this is useful:
88: HttpPost post = null;
89: post = new HttpPost(url);
91: post.addHeader("Content-Type", "multipart/related;
boundary=\"END_OF_PART\"");
92: post.addHeader("MIME-version", "1.0");
93:
116:
117: HttpEntity body = new ByteArrayEntity(bodyBytes);
118: post.setEntity(body);
121: HttpResponse resp = uploadClient.execute(post);
Instead of ByteArrayEntity sounds like you want InputStreamEntity or such
like...
*BUT: *In my experience using an InputStreamEntity is bad because over flaky
connections the HttpClient sometimes attempts to resend packets and the
InputStreamEntity is "not-repeatable"... (You'll get periodic
EntityNotRepeatable errors). Which is why I switched to using a
ByteArrayEntity as above which seems to work slightly better for large
streams.
Hope that answers your question,
Best,
Adam.
On Sat, Nov 22, 2008 at 2:39 PM, fala70 <[EMAIL PROTECTED]> wrote:
>
> Hi, I've a problem to translate follow code to org.apache.http.*;
>
> OutputStream pos = new OutputStream();
> pos.writeShort(Const.INVOCATION_CODE);
> pos.writeInt(requestId);
> pos.writeString(nickname);
> pos.writeString(password);
>
> conn = (HttpConnection) Connector.open(url,
> Connector.READ_WRITE);
> conn.setRequestMethod(HttpConnection.POST);
> conn.setRequestProperty("Content-Type", "application/octet-
> stream");
> conn.setRequestProperty("Accept", "application/octet-stream");
>
> if(sessionCookie == null)
> {
> conn.setRequestProperty("version", "???");
> }
> else
> {
> conn.setRequestProperty("cookie", sessionCookie);
> }
>
>
> // Getting the output stream may flush the headers
> os = conn.openDataOutputStream();
> os.write(pos.getBytes());
> os.close();
>
>
> start connection I must use :
> HttpClient conn = new DefaultHttpClient();
> HttpPost httppost = new HttpPost(url);
>
> but I've difficult to understand what must I use to set the request
> proprieties (setRequestProperty) and use an OutputStream to send my
> requests
>
> thanks
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---