| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		mdoigny -
 
  Joined: 24 May 2008 Posts: 16 Location: Oostende, Belgium
  | 
		
			
				 Posted: Wed May 28, 2008 7:44 am    Post subject: Swich from Xitami to Abyss | 
				      | 
			 
			
				
  | 
			 
			
				http://idemdito.org
 
 
If you look at the stats it took some 10 days to configure the new server, rescue the webpages directory, install the software and get it running. Each evening after my normal work i worked on the server. The old server (and associated software) was from 1999. _________________ Home server | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		admin Site Admin
 
  Joined: 03 Mar 2002 Posts: 1348
 
  | 
		
			
				 Posted: Mon Jun 02, 2008 7:10 pm    Post subject: Re: Swich from Xitami to Abyss | 
				      | 
			 
			
				
  | 
			 
			
				mdoigny,
 
 
Congratulations for the move to Abyss Web Server and glad to know that you chose our software to host your sites. _________________ Follow @abyssws on Twitter
 
Subscribe to our newsletter
 
_________________
 
Forum Administrator
 
Aprelium - https://aprelium.com | 
			 
		  | 
	
	
		| Back to top | 
		
			          | 
		
	
	
		  | 
	
	
		mdoigny -
 
  Joined: 24 May 2008 Posts: 16 Location: Oostende, Belgium
  | 
		
			
				 Posted: Mon Jun 02, 2008 7:23 pm    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				Still struggling with pipes...
 
test html
 
 	  | Code: | 	 		  <html><body>
 
<form action='http://...server.../cgi/env.exe' method='post' enctype='multipart/form-data'>
 
<input type='file' name='filename.jpg'><br>
 
<textarea name='description' rows=5 cols=60>Korte beschrijving van de foto (niet verplicht) - Description de la photo (facultatif)</textarea>
 
<input type='hidden' value='0123456789' name='record'>
 
<input type='submit' value='send file'></form>
 
</body></html>"
 
 | 	  
 
 
CGI source (powerbasic PBCC4)
 
 	  | Code: | 	 		  
 
DEFINT a-z
 
FUNCTION PBMAIN()
 
 
    STDOUT "HTTP/1.1 200 OK"
 
    STDOUT "Content-Type: text/plain
 
    STDOUT
 
    STDOUT "Command: " + COMMAND$
 
    STDOUT "Query string: " + ENVIRON$("QUERY_STRING")
 
    STDOUT
 
 
    WHILE NOT STDEOF
 
        STDIN LINE a$
 
        STDOUT a$
 
    WEND
 
 
    a$ = ENVIRON$(1): i = 1
 
    WHILE LEN(a$)
 
        STDOUT a$
 
        INCR i
 
        a$ = ENVIRON$(i)
 
    WEND
 
 
END FUNCTION
 
 | 	  
 
Works with non-binary data (uploading text files), hangs when uploading binary data (like JPEG).
 
Basically:
 
STDIN LINE: read one line from STDIN pipe
 
STDOUT: write to STDOUT pipe
 
STDEOF: boolean eof-condition
 
I think i will need raw API calls to get past CONTROL-Z _________________ Home server | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		admin Site Admin
 
  Joined: 03 Mar 2002 Posts: 1348
 
  | 
		
			
				 Posted: Wed Jun 04, 2008 5:02 pm    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				 	  | mdoigny wrote: | 	 		  
 
CGI source (powerbasic PBCC4)
 
 	  | Code: | 	 		  
 
    WHILE NOT STDEOF
 
        STDIN LINE a$
 
        STDOUT a$
 
    WEND
 
 
 | 	 
  | 	  
 
 
We're not PB experts but your code seems to be using using the standard input as a text stream while it has to be used as a binary stream (with no EOF, no end of line conversion).
 
 
So to solve the problem, do not use STDEOF but rather rely on the number of bytes available in the environment variable CONTENT_LENGTH. STDIN has also to be opened/read as a binary stream.
 
 
The above recommendations are not specific to our server only. It is how CGI applications must behave ( http://hoohoo.ncsa.uiuc.edu/cgi/in.html ).
 
 
A quick look on PB public documentation suggests that you'll have to use the following statements to open teh standard input as a binary stream:
 
 
 	  | Code: | 	 		  hStdIn& = GETSTDIN
 
OPEN HANDLE hStdIn& FOR BINARY ACCESS READ AS #1 | 	  
 
 
To read the posted payload:
 
 
 	  | Code: | 	 		  cl = VAL(ENVIRON$("CONTENT_LENGTH"))
 
GET$ #1, cl, payload$ | 	  
 
 
Then close the input stream:
 
 
 
 
The code may contain syntax errors but it is mainly intended to suggest the PB functions/routines to use. _________________ Follow @abyssws on Twitter
 
Subscribe to our newsletter
 
_________________
 
Forum Administrator
 
Aprelium - https://aprelium.com | 
			 
		  | 
	
	
		| Back to top | 
		
			          | 
		
	
	
		  | 
	
	
		mdoigny -
 
  Joined: 24 May 2008 Posts: 16 Location: Oostende, Belgium
  | 
		
			
				 Posted: Wed Jun 04, 2008 6:53 pm    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				You can add one satisfied customer to your user base!
 
It's somehow strange, but i had to perform multiple inputs, as if the GET$ statement is getting only one TCP packet each time (even using a long SLEEP of 1 second each iteration)
 
The code that did the trick is the following:
 
 	  | Code: | 	 		  ....
 
    c = VAL(ENVIRON$("CONTENT_LENGTH"))
 
    STDOUT "Data Length: " + FORMAT$(c)
 
    h = GETSTDIN
 
    f = FREEFILE: OPEN HANDLE h FOR BINARY ACCESS READ AS #f
 
    b$ = ""
 
    GET$ #f, c, a$
 
    WHILE LEN(a$)
 
        b$ = b$ + a$          'bad coding but OK for an example
 
        GET$ #f, c, a$
 
        SLEEP 1000
 
        STDOUT STR$(LEN(a$))   'testing 
 
    WEND
 
    CLOSE
 
....
 
 | 	 
  _________________ Home server | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		mdoigny -
 
  Joined: 24 May 2008 Posts: 16 Location: Oostende, Belgium
  | 
		
			
				 Posted: Sat Jun 07, 2008 12:52 pm    Post subject:  | 
				      | 
			 
			
				
  | 
			 
			
				Just FYI for those still using classic style CGI.
 
Don't mix STDIN and STDOUT statements (or their API calls equivalents).
 
Seems to be a bug in windows. Just read all your input, process the data, and then issue the output.
 
This windows bug creates very hard to track errors. It's purely windows-related, since the error occurs also when using pipes
 
 	  | Code: | 	 		  | type "large file.txt" | CGIapplication | 	 
  _________________ Home server | 
			 
		  | 
	
	
		| Back to top | 
		
			           | 
		
	
	
		  | 
	
	
		 |