Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 2018 17:34
    @greggirwin banned @BIjeuca_twitter
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:20
    @PeterWAWood banned @TimeSeriesLord
WayneCui
@WayneCui
@dockimbel Thanks Doc, my CLI is too old. It works with a new version
WayneCui
@WayneCui
Red []

from-timestamp: func [ ts ][
   return 1970-01-01 + to time! round/down ts / 1000 
]

hessian-proxy: make object! [

    run: func[ method ][
        data: rejoin [to-binary "c^A^@m" (at to-binary length? method 7) to-binary method to-binary "z"]
        result: write http://hessian.caucho.com/test/test compose [
            post [
                Host: "hessian.caucho.com"
                Content-type: "application/x-hessian"
                Accept-Encoding: "identity"
                User-Agent: "rebol-hessian/0.0.1"
                Accept-Charset: "*"
            ]
            (data)
        ]

        print to-binary result
        probe from-timestamp to-integer copy/part at result 5 8
    ]
]

hessian-proxy/run "replyDate_1"
image.png
>rebol3 hessian-red.red
#{72010064000000D04B9284B87A}
8-May-1998/9:51:31

> red-latest hessian-red.red 
#{
72010066530004636F64655300154E6F537563684D6574686F64457863657074
696F6E5300076D65737361676553002B54686520736572766963652068617320
6E6F206D6574686F64206E616D65643A20706C79446174655F317A7A7A
}
*** Script Error: cannot MAKE/TO integer! from: "S^@^DcodeS"
*** Where: to
*** Near : probe from-timestamp to-integer copy/part 
*** Stack: run probe from-timestamp to-integer
WayneCui
@WayneCui
Hello, I am working on a hessian client project,sending/receiving binary data over HTTP. It seems there is something not working well about Red HTTP
ne1uno
@ne1uno
{r^A^@fS^@^DcodeS^@^UNoSuchMethodExceptionS^@^GmessageS^@+The service has no method named: plyDate_1zzz}
ne1uno
@ne1uno
@WayneCui, at maybe needs series!? try something like (to binary! at form to-hex length? method 8)
WayneCui
@WayneCui
Thanks @ne1uno , I know what's wrong
WayneCui
@WayneCui
request is correct, another error
WayneCui
@WayneCui
#{6301006D000B7265706C79446174655F317A}
*** Access Error: invalid UTF-8 encoding: #{D04B9284}
*** Where: write
*** Near : result: write http://hessian.caucho.com/ 
*** Stack: run
Red []

from-timestamp: func [ ts ][
   return 1970-01-01 + to time! round/down ts / 1000 
]

hessian-proxy: make object! [

    run: func[ method ][
        ; probe data: rejoin [to-binary "c^A^@m" (to-binary at form to-hex length? method 8) to-binary method to-binary "z"]
        probe data: rejoin [to-binary "c^A^@m" (at to-binary length? method 3) to-binary method to-binary "z"]
        result: write http://hessian.caucho.com/test/test compose [
            post [
                Host: "hessian.caucho.com"
                Content-type: "application/x-hessian"
                Accept-Encoding: "identity"
                User-Agent: "rebol-hessian/0.0.1"
                Accept-Charset: "*"
            ]
            (data)
        ]

        probe "==========="
        print to-binary result
        probe from-timestamp to-integer copy/part at result 5 8
    ]
]

hessian-proxy/run "replyDate_1"
ne1uno
@ne1uno
(at to-binary length? method 4) ?
seems like it's looking fo 2 byte length, not 1 or 4
WayneCui
@WayneCui
I think it's about the response. Request is the same with Rebol
WayneCui
@WayneCui
Simplified the code, but this url (http://hessian.caucho.com/test/test) has often been timeout :-/
Red []

data: #{6301006D000B7265706C79446174655F317A}
probe result: write http://hessian.caucho.com/test/test compose [
    post [
        Host: "hessian.caucho.com"
        Content-type: "application/x-hessian"
        Accept-Encoding: "identity"
        User-Agent: "rebol-hessian/0.0.1"
        Accept-Charset: "*"
    ]
    (data)
]
>redl hessian-red.red  
*** Access Error: invalid UTF-8 encoding: #{D04B9284}
*** Where: write
*** Near : data: #{6301006D000B7265706C79446174655F 
*** Stack: probe 

>rebol3 hessian-red.red
#{72010064000000D04B9284B87A}
WayneCui
@WayneCui
It seems Red try to explain response data as UTF-8
image.png
ne1uno
@ne1uno
why compose? I got a 404 using reduce instead
= {<html>^/<head><title>404 Not Found</title></head>^/<body>^/<h1>404 Not Found</h1>^//test/test2%A0 was not found ...
WayneCui
@WayneCui
compose evaluates a block of expressions, only evaluating parens, and returns a block. (http://www.rebol.com/r3/docs/functions/compose.html)
ne1uno
@ne1uno
I get the 404 now with compose too. not a utf8 error
ne1uno
@ne1uno
could it be a hessian v1 v2 v3 thing?
if r3 works, must be something in the post is different
WayneCui
@WayneCui
Never met that. Is there any typo? Can you open http://hessian.caucho.com/test/test in the browser?
ne1uno
@ne1uno
Hessian Requires POST
seems to work
ne1uno
@ne1uno
I used to have a proxy to look at messages in or outgoing, haven't done that in awhile.
ne1uno
@ne1uno
should I be using the I/O branch maybe? woops
ne1uno
@ne1uno
same w/older red I/O
ne1uno
@ne1uno
Red 0.6.4 for Windows built 18-Jul-2022/15:26:27-05:00 commit #d09220b
ne1uno
@ne1uno
@WayneCui, which red version are you using? continuing in https://gitter.im/red/IO
WayneCui
@WayneCui
@ne1uno Red 0.6.4 for Mac Cli, November 20 or 21
the same with red-24nov22-e6ae842b4 for Mac cli
ne1uno
@ne1uno
@WayneCui, try separating the odata: compose ... from the write ... odata, it might improve the error message?
Gregg Irwin
@greggirwin
Have you tried using /binary?
ne1uno
@ne1uno
/binary same w/recent. current red IO, write seems not to handle a block after the url at all
Gregg Irwin
@greggirwin
With current main branch:
data: #{6301006D000B7265706C79446174655F317A}
probe result: write/binary http://hessian.caucho.com/test/test compose [
    post [
        Host: "hessian.caucho.com"
        Content-type: "application/x-hessian"
        Accept-Encoding: "identity"
        User-Agent: "rebol-hessian/0.0.1"
        Accept-Charset: "*"
    ]
    (data)
]
== #{72010064000000D04B9284B87A}
ne1uno
@ne1uno
^works recent cli not view. there was a Unicode space or control code between /test and compose I picked up from copy & paste that errored.
WayneCui
@WayneCui
@greggirwin It works, thanks a lot
WayneCui
@WayneCui
>> to-integer #{000000D04B9284B8}
== 208
>> to-binary 208
== #{000000D0}
>> to-integer #{D04B9284B8}
== -800353660
>> to-binary -800353660
== #{D04B9284}
When convert a binary! to integer! , it seems only first 4 byte matters. Or there is other ways for this converting ?
In rebol3 , I can do this:
>> to-integer #{000000D04B9284B8}
== 894621091000

>> to-binary 894621091000
== #{000000D04B9284B8}
to-float can not work either
--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> to-float #{000000D04B9284B8}
== 0.0
>> to-number #{000000D04B9284B8}
*** Script Error: to-number has no value
*** Where: catch
*** Near : to-number #{000000D04B9284B8}
*** Stack:
Oldes Huhuman
@Oldes
There is no to-number. number! is not datatype. It is a typeset:
>> ? number!
NUMBER! is a typeset! value: [integer! float! percent!]
And Red has only 32bit integer and float values:
>> to binary! 1
== #{00000001}
Oldes Huhuman
@Oldes
Years ago I used my Stream-IO written in Red/System for binary conversions in Red.
Gregg Irwin
@greggirwin
As @Oldes noted, there are no 64-bit ints in Red yet.
WayneCui
@WayneCui
I see, thanks for your info @Oldes @greggirwin