Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Circular forwarding, once again

From: gscottjones:mchsi at: 2-Aug-2002 9:36

From: "Charles"
> Argh. Not to be a complete dumbass, but I took a look at e-scribe for
> on the circular forwarding problem, and .. well, found a couple things,
> also a some successive posts that said it didn't work right. For
instance, I
> found these two: > > > > Although, I'm not clear on how I should add this change. Copy&paste
> entire block of code with the suggested change before loading my actual
> What if one were to simply (in post m11480) replace the code which causes
> to dump on circ forward and instead carry on?
Hi, Charles, There are at least two ways to achieve the change mentioned by Maarten in the archived email. One way is to create your own copy of the http scheme, edit it with your favorite text editor, then load the scheme into REBOL. One way to do this is to: 1) Open fresh REBOL console 2) Type "echo %/path/to/a/file/my-http.r" and return key 3) Type "probe system/schemes/http" and return key 4) Type "quit" and return key Then go to the directory where you choose to save the file, and open the file with your favorite text editor. Remove the ">>" at the beginning of the file and insert "system/schemes/http:" just before the word "make". Then remove the ">>" from the end of the file and save. This is the RT version of the http scheme. Now, scanning down the file, locate the 'handler object, then the 'open function within the 'handler object, then the 'forward block in 'open. Toward the end of this block, you will see the line that Maarten referred to "build-port". Following this line, insert that line that he recommended trying: http-get-header/host: port/host then save the altered scheme. Now at a fresh REBOL console, load that scheme with something like do %/path/to/a/file/my-http.r Note, that this method *replaces* the default scheme with your new http scheme in the current session only. Now work on the circular forwarding problem to your heart's content. The alternative approach to "patching" REBOL requires some trial and error. In my version of REBOL/View, the following will locate the scheme as it exists at runtime and insert the desired line directly: insert next find second get in system/schemes/http/handler 'open 'build-port reduce [to-set-word "http-get-header/host" 'port/host] Watch for the line wrap (this should all be on one line in the script or console). In addition to trial and error, this method is also potentially more fragile, hence some people's preference to copy the scheme to a file and make changes there.
> Even better, though, would be to take this first address, perform... I
> know, SOME function on it to find out what the REAL URL should be, and let
> access that - server and subdirs all together. I would really like to try
> do this without messing with system functions... *sighs*
There is a way to capture the information that you seek by directly using the ports, but my guess is that you will end up with a less flexible reimplementation of what is already a part of the http scheme. You can of course hack the http scheme protocol to capture the information during processing, but you might as well add the functionality you seek right into the scheme in use, or you will find yourself having to "always" make at least two calls for each url access (first to find if it is forwarded then a second call to the next url). Maarten's basic approach is to let the scheme automatically manage a forwarding request, but as he implies, it may not be fully tested. It has been over a year since I played with a forwarding problem. If his suggested addition does not accomplish your need, let the list know, along with the url, and we may be able to hack a more robust patch. Hope this helps. --Scott Jones