hi forthers,
I am trying to do a (very simple and naive) http-request
with gforth (current from git):
[...]
[email protected] writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
- What is the best way, to convert an sstring to a cstring? I was
wondering, that there is a cstring>sstring in gforth, but not the
other way sstring>cstring?
: >cstring ( addr u -- c-string-addr )
[ s\" \0" ] 2literal s+ drop ;
s" GET" >cstring constant method-get
s" POST" >cstring constant method-post
s" PUT" >cstring constant method-put
s" DELETE" >cstring constant method-delete
s" PATCH" >cstring constant method-patch
[email protected] writes:
[email protected] writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
It seems to me that variable-flavoured locals would work here, i.e.:
: http-request ( method url-addr url-len -- status content-addr content-len )
{: w^ curl-data w^ response-code :}
[email protected] (Anton Ertl) writes:
[email protected] writes:
[email protected] writes:
- I use global variables (in the dictionary) for curl-data and
response-code. What would be the right way to do this locally in
http-request? The usual locals are on a stack IMHO - so I would need
to allocate cells?
It seems to me that variable-flavoured locals would work here, i.e.:
: http-request ( method url-addr url-len -- status content-addr content-len ) >> {: w^ curl-data w^ response-code :}
Actually:
: http-request ( method url-addr url-len -- status content-addr content-len )
0 0 {: w^ curl-data w^ response-code :}
- anton
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,076 |
| Nodes: | 10 (1 / 9) |
| Uptime: | 81:17:39 |
| Calls: | 13,805 |
| Files: | 186,990 |
| D/L today: |
7,204 files (2,402M bytes) |
| Messages: | 2,443,304 |