r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[CGI] web server issues

DanielSz
25-Jul-2007
[668]
Thanks for the help. The recipe from the rebol cookbook show you 
how to upload a file provided the server runs a rebol script too. 
The server I'm uploading a file to doesn't. It expects multipart/form-data. 
Maybe the %cgi.r by Cal Dixon provides a solution. I'll investigate 
further. More hints will be appreciated, as well...
btiffin
25-Jul-2007
[669]
Try this ML thread http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlKVSQ
and some notes by Sunanda on CGI 'safety' 

http://www.rebol.org/cgi-bin/cgiwrap/rebol/art-display-article.r?article=x60
DanielSz
25-Jul-2007
[670x2]
In that ML thread, the request was to handle a multipart upload on 
the server side (in rebol). I need to perform a multipart upload 
on the client side (in rebol). As for the seconde link, unfortunately 
I get "Article x60 is no longer available ". Any idea?
In other words, the rebol script has to send values to a form on 
the server issuing something like that in the header: Content-Type: 
multipart/form-data; boundary=----------6l5Xq9lJYPaaypknAH8Des etc. 
Surely someone has done this before (I hope)...
btiffin
25-Jul-2007
[672x2]
My bad. http://www.rebol.org/cgi-bin/cgiwrap/rebol/art-display-article.r?article=x60w
 but unfortunately this article skips over the info for multipart/form.
Try http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlRDSC


But to be honest, I've been waiting for Graham or Dockimbel to notice 
the conversation.   My exposure to this sequence is purely "little 
think cut'n'paste" from the cookbook, since I'm REBOL in, REBOL out 
for the website I run.  :)
Graham
25-Jul-2007
[674x2]
Oldes' script looks like it should do the job.
this is an article I wrote in 2003 hacking the http protocol to do 
this too http://www.compkarori.com/vanilla/display/HTTP+file+uploading
DanielSz
26-Jul-2007
[676]
Thanks, Graham, you hit the right spot. Like you say in your article, 
"Read/Custom sets the port to lines modes, and there is no clean 
way to change this to binary for binary uploads". But that's exactly 
what I need. Which script by Oldes are you referring to? Where can 
I find it? Are you saying that his is doing the job?
btiffin
26-Jul-2007
[677]
The last ML entry I mentioned has the reference to Olde's script. 
 rmlRDSC  If it does the job of tweaking the lines mode?  Haven't 
looked.
Graham
26-Jul-2007
[678x2]
I don't know if it helps, but I did write a web server stress test 
that did a http upload of hundreds of images in Rebol that year.. 
but the scripts are long lost.
I used a variant of the http-tools.r script, composed the correct 
header, and then insert the headers, and then switched the port to 
binary before inserting the payload
DanielSz
26-Jul-2007
[680x2]
Ok, I'll try to hack the http-tools.r, see if I can get anything 
done. I saw a script written in python claiming to do multipart uploads, 
but I hope I can get it working in Rebol, which for me is always 
first choice.
Thanks everybody. I'll keep you posted.
Volker
26-Jul-2007
[682x3]
what are you doing? still uploading binary? then use open/insert/close 
and change port to binary if it is open
hmm, does open/custom do that. i hope..
i guess i am on the wrong track..
DanielSz
26-Jul-2007
[685]
I played with Oldes script a bit, didn't get far. I think there's 
no other option than follow Graham's advice and delve in the http 
scheme. I had hoped to find something in the script archive, oh well... 
I saw that even in the Ruby and Python community there's some confusion 
on how to achieve multipart form submissions with CGI. (Python default 
http library also uses  "application/x-www-form-urlencoded" and not 
""multipart/form-data", but there's a library called HTTPFileUploader 
that does the job). Last time I tried to hack the http scheme I wasn't 
so succesful. This time, if I need help, I'll ask for help.
Volker
26-Jul-2007
[686]
do you need to write binary, or a multipart?could be multipart can 
use base64. then its somewhat bigger, but has no problems with text-mode. 
could even be that multipart of email works the same. in that case 
there is 'build-attach-body.
DanielSz
26-Jul-2007
[687x3]
The script should be able to post a multipart form as described in 
rfc1867. It should be able to post a number of fields, for example: 
Content-Disposition: form-data; name="userid", and finally it should 
be able to upload a file in binary data.
Graham described what needs to be done (I used a variant of the http-tools.r 
script, composed the correct header, and then insert the headers, 
and then switched the port to binary before inserting the payload). 
Only it's a little a bit above my capacities. In other words, I'll 
need two weeks to do it, if I ever manage it.
Graham, I'm a big fan of http-tools.r (I believe you wrote it,right?). 
I used it in my DYNdns client that I wrote in Rebol. I realized only 
recently that some of the functionality was built-in.(Basic authenticaion 
with read/custom). Grrrr... if only you hadn't thrown those upload 
scripts away :)
Graham
26-Jul-2007
[690]
Daniel, I wrote http-tools.r before there was a read/custom .. that's 
how old the script is!
DanielSz
26-Jul-2007
[691]
Yeah, I remember some tips you contributed to the rebolzine on posting 
to web forms, way back... Anyway, I think I won't tinker with the 
http scheme, kinda dpressing thought, especially since I have great 
hopes to achieve what I need using curl and the shell capability 
of Rebol. Let curl do that work, afte r all, that's what' it's meant 
to do best.
Graham
26-Jul-2007
[692x2]
I found the script .. written in 2002.
Undocumented .. but basically it took a directory of jpegs and zip 
files and uploaded them to a java based webserver that required custom 
headers
DanielSz
26-Jul-2007
[694x2]
Great, can I see it?
And the good news is: curl does it flawlessly. I just saved myself 
two weeks of headaches. I am a reboller, but not a purist, if I find 
a better tool to do something, that's cool with me.
Graham
26-Jul-2007
[696]
Sent.
DanielSz
26-Jul-2007
[697]
Received. Thanks, indeed.
james_nak
30-Aug-2007
[698]
Anyone know the answer to this one? 

I have a cgi script that sends an email out. The problem is that 
I want to send to an address that has the same domain name as the 
website but whose mail server is not located there (It's an Exchange 
Server). Any other address works fine as expected. I think it has 
to do with the mx records but, the weird thing is that if I generate 
an email via php, it goes through. Therefore I'm thinking Rebol can 
do it too. 

I've used set-net  for the smtp server and have set it a different 
server completely but still no go.
And I'm in the process of having the MX records changed.
Graham
30-Aug-2007
[699]
what is the trace/net say?
james_nak
31-Aug-2007
[700]
Oh, Haven't tried that. I'll see.
Gabriele
31-Aug-2007
[701]
usually PHP uses the sendmail command directly, not SMTP, so it can't 
be compared unfortunately (ie the fact tha php can send mails does 
not guarantee that rebol can). but, you could use CALL and call sendmail 
directly too if there is no other option.
Graham
31-Aug-2007
[702]
why not try using set-net [ email localhost ]
james_nak
6-Sep-2007
[703]
Thanks all. In the end I switched hosts and their mx records work 
so problem solved.
Pekr
17-Sep-2007
[704x3]
I mentioned the possibility (to overcome REBOL web-hosting) to place 
rebol executable directly in the /cgi-bin/ directory. Someone on 
ML mentioned I should not do that, security wise, as calling http://www.my-domain/cgi-bin/rebol
will spawn a process, which will run endlessly or so ...
I just wanted to ask - wasn't there some change in the past, to prevent 
such case? Would it be sufficient to rename rebol.exe to something 
like EDB433BDD7C13851C7C68CB31A5ACF33A80CD2CC? :-)
Or what about building special rebol version using SDK, running by 
default in cgi mode, quitting imediatelly, if there is not get or 
post string?
Chris
17-Sep-2007
[707]
My understanding is the latter would be slower.  Also, QM (as an 
example) doesn't generally require a get query or post data (primarily 
uses path info).
Gabriele
18-Sep-2007
[708]
petr, it is much better to just put rebol in another dir. there is 
no reason to have it in /cgi-bin/
Pekr
18-Sep-2007
[709x3]
aha, but can it be dir of my own site?
I mean - let's say I don't have telnet available - just ftp to upload 
my site ...
but even then, putting it in another dir, in order to be able to 
run rebol, I have to set it as runnable too, no? So what is the difference 
in having it in cgi-bin or other directory, if permissions have to 
be equal?
Rebolek
18-Sep-2007
[712]
Pekr, well they don't have to. Script's permissons are different 
from some random visitor's permissions. Script is local and not remote.
Gabriele
18-Sep-2007
[713]
the scripts have to be in cgi-bin, the interpreter can (and should) 
be somewhere else, where it is not accessible.
Pekr
18-Sep-2007
[714]
Gabriele - where it is not accessible? That means I need other then 
FTP access. That ruins easy REBOL deployment ...
Gabriele
18-Sep-2007
[715]
why? ftp access only gives access to cgi-bin? usually, you have your 
own home dir, with www and cgi-bin dirs inside.
Pekr
18-Sep-2007
[716x2]
I'll check, but with hosting I have I seem to have root set to my 
web root.
So, in terms of my website, if I put rebol executable e.g. into /rebol/rebol.exe, 
is it any different security-wise to /cgi-bin/rebol.exe?