[REBOL] Re: HTTP-Post Error
From: rebol-list2:seznam:cz at: 19-Oct-2002 10:10
Hello Graham,
Thursday, October 17, 2002, 9:25:00 AM, you wrote:
>>It's been working beautifully in the past with some help
>>from you REBOL genious' but now occasionally I seem to
>>get a "HTTP/1.1 500 Internal Server Error".
>>
>>http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new?
GC> Perhaps the server code is dying because of the extra "?"
GC> you've added here. The "?" is used when using the GET
GC> method, but not with POST.
GC> Also, have you tried using 'read as in
GC> read/custom
GC> http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new [ ...
GC> ]
GC> to POST your message?
GC> --
GC> Graham Chiu
Yes, the read/custom and open/custom is very useful, some pages needs to be accesed
only from some pages so the 'Referer and 'Host in the header must be set
correctly, I'm using for example this code (and will have to add this
to my %reb-web-bot.r script as well):
This is not complete code, because first I want to make some code
cleaning before puclicating it:-) only important parts are here now:
port: open/direct/binary/custom http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2
[
header [
User-Agent: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
Referer: "http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2"
Host: "www2.eurotel.cz"
]
]
probe port/locals
cookie: port/locals/headers/set-cookie
buffer: make binary! 8000
set-modes port/sub-port [lines: false binary: true no-wait: true]
until [
if not data: wait [60 port/sub-port] [data: true break]
if data: copy port/sub-port [append buffer data]
not data
]
close port
;some page parsing is here.....
;...after the parsing I have: poststr with the url-encoded postdata
;so I can send them:
print read/custom rejoin [http:// port/host %/sms/index.html] x: compose/deep [
header [
User-Agent: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
Referer: "http://www2.eurotel.cz/sms/index.html?n_pagestyle=new2"
Host: "www2.eurotel.cz"
Cookie: (cookie)
]
post (poststr)
]
buffer: make binary! 8000
set-modes port/sub-port [lines: false binary: true no-wait: true]
until [
if not data: wait [60 port/sub-port] [data: true break]
if data: copy port/sub-port [append buffer data]
not data
]
close port
print buffer: to-string buffer