Whenever i try to write bytes to the outpustream with this code:
B4X:
Dim r As Reflector
r.Target = Response
Dim jo As JavaObject = r.GetField("res")
Dim ser As B4XSerializator
Dim out As OutputStream = jo.RunMethod("getOutputStream", Null)
Dim data() As Byte = ser.ConvertObjectToBytes( Object )
out.WriteBytes( data, 0, data.Length )
i get java.io.EOFException: Unexpected end of ZLIB input stream at client side.
B4X:
Sub JobDone ( j as httjob )
if j.success then
dim data() as byte = bit.inpustreamtobytes( j.getinpustream) '< '-- Error
end if
End Sub
Dim out AsOutputStream = jo.RunMethod("getOutputStream", Null) Dim data() As Byte = ser.ConvertObjectToBytes( Object )
out.WriteBytes( data, 0, data.Length )
Waiting for debugger to connect...
Program started.
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
at java.io.DataInputStream.readByte(DataInputStream.java:265)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:133)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:301)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:112)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:82)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator$2.call(B4XSerializator.java:93)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator$2.call(B4XSerializator.java:1)
at anywheresoftware.b4a.BA$4.run(BA.java:272)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Error reading response: (EOFException) java.io.EOFException: Unexpected end of ZLIB input stream
I don’t think that b4xserializator can do that. I think it’s only primitives, arrays, lists, types and maps. Arrays, list, types and maps can contain other arrays, list, types and maps.
I don’t think that b4xserializator can do that. I think it’s only primitives, arrays, lists, types and maps. Arrays, list, types and maps can contain other arrays, list, types and maps.
You misunderstood my question.
it has nothing to do with b4serializator. I'm converting a map ( CreateMap("test": "test") to bytes and then trying to send it over to the outpustream.
Actually, I've overlooked the forum (B4A). I was thinking in terms of B4J. And yes, I also misunderstood what you are sending. So sort of ignore everything I've said so far.
The flush may be the wrong thing to do. A hint from this post (https://stackoverflow.com/a/5045073) indicates that ContentLength should be greater than 0 in order for the underlying servlet to recognize that it is done and flush the output stream. So you may need:
B4X:
'
Dim r As Reflector
r.Target = Response
Dim jo As JavaObject = r.GetField("res")
Dim ser As B4XSerializator
Dim out As OutputStream = jo.RunMethod("getOutputStream", Null)
Dim data() As Byte = ser.ConvertObjectToBytes( Object )
jo.RunMethod("setContentLength", Array(data.Length)) '<--- This may do the trick
out.WriteBytes( data, 0, data.Length )