5f900c0b68
* NEW: English and french tips were updated. A new tip was added. * NEW: Files that were opened at project close are automatically reopened when the project is loaded again. * NEW: A warning message is displayed when the GNU translation tools are not installed. * BUG: The code editor method combo-box is correctly updated now. * BUG: Some fixes in the automatic completion. * BUG: Replace points by dash in the name of packages generated by the IDE packager. * NEW: Updated russian translation * NEW: Updated french translation [DATABASE MANAGER] * NEW: Updated russian translation [EXAMPLES] * BUG: Fixed the Gravity and the GameOfLife examples so that they do not use public form controls anymore. [INTERPRETER] * OPT: Many optimizations in the string substitution routines, the internal datatype conversions, the INPUT and LINE INPUT instructions, the error messages generation, the object and string reference counting, and the memory allocation routines. * NEW: Opening a device file in direct mode (FOR READ/WRITE) is now automatically non blocking. * OPT: Lof() now only tries its different methods (ioctl and lseek) once. * BUG: Val() now ignores thousand separators characters at the end of the number. * NEW: A new flag for enabling the stack trace generation at each error. [GB.DEBUG] * BUG: The gb.debug component interface declaration was not 64-bits aware. [GB.EVAL] * BUG: The Highlight.Purge() method now correctly deals with non-ASCII characters. [GB.FORM] * BUG: TableView.Edit() does not raise a "read-only combo-box" error anymore. [GB.FORM.DIALOG] * BUG: Dialog buttons now are never cut. [GB.GTK] * BUG: Cached drawing areas are correctly redrawn now. * BUG: Loading big images now works correctly. There is apparently a bug in the GTK+ image loader, and I found a workaround. * BUG: Message boxes correctly display the text of their buttons now. [GB.QT] * BUG: The Open, and initial Move and Resize event of embedded forms are now always raised when you call the Show method or if you set the Visible property. Before, it was raised when the embedded form was actually shown. [GB.SETTINGS] * NEW: Settings are now stored in ~/.config/gambasX, where X is the gambas version number. * BUG: Strings are correctly quoted inside the settings file now. [GB.WEB] * NEW: Application.Protocol is a new property that allows to tell the component that the protocol is not necessarily "http". git-svn-id: svn://localhost/gambas/trunk@1153 867c0c6c-44f3-4631-809d-bfa615b0a4ec
174 lines
3.1 KiB
Text
174 lines
3.1 KiB
Text
' Gambas module file
|
|
|
|
EXPORT
|
|
|
|
PROPERTY Buffered AS Boolean
|
|
PROPERTY ContentType AS String
|
|
PROPERTY Status AS String
|
|
|
|
PRIVATE $bBuffered AS Boolean
|
|
PRIVATE $sHeader AS String
|
|
PRIVATE $sRedirect AS String
|
|
PRIVATE $hFile AS File
|
|
PRIVATE $sContentType AS String = "text/html"
|
|
PRIVATE $sStatus AS String
|
|
PRIVATE $bBegin AS Boolean
|
|
|
|
PUBLIC SUB AddHeader(Name AS String, Value AS String)
|
|
|
|
IF NOT Value THEN RETURN
|
|
$sHeader &= Name & ": " & Value & "\r\n"
|
|
|
|
END
|
|
|
|
PUBLIC SUB Redirect(URL AS String)
|
|
|
|
IF $bBegin THEN RETURN
|
|
|
|
IF URL LIKE "*://*" THEN
|
|
AddHeader("Location", URL)
|
|
ELSE
|
|
AddHeader("Location", Application.Protocol & "://" & CGI["HTTP_HOST"] &/ URL)
|
|
ENDIF
|
|
|
|
Response.Begin
|
|
Response.End
|
|
|
|
END
|
|
|
|
PUBLIC SUB SetCookie(Cookie AS String, Value AS String, OPTIONAL Domain AS String, OPTIONAL Path AS String, OPTIONAL Expires AS Date)
|
|
|
|
DIM sVal AS String
|
|
|
|
sVal = Cookie & "=" & Value
|
|
IF Domain THEN sVal &= ";domain=" & Domain
|
|
IF Expires THEN sVal &= ";expires=" & CGI.FormatDate(Expires)
|
|
IF Path THEN sVal &= ";path=" & Path
|
|
|
|
AddHeader("Set-Cookie", sVal)
|
|
|
|
END
|
|
|
|
PUBLIC SUB RemoveCookie(Cookie AS String, Value AS String, OPTIONAL Domain AS String, OPTIONAL Path AS String)
|
|
|
|
DIM sVal AS String
|
|
|
|
sVal = Cookie & "=" & Value
|
|
IF Domain THEN sVal &= ";domain=" & Domain
|
|
sVal &= ";expires=" & CGI.FormatDate(Now - 1)
|
|
IF Path THEN sVal &= ";path=" & Path
|
|
|
|
AddHeader("Set-Cookie", sVal)
|
|
|
|
END
|
|
|
|
PUBLIC SUB Begin()
|
|
|
|
IF $bBegin THEN RETURN
|
|
|
|
IF $sStatus THEN AddHeader("Status", $sStatus)
|
|
AddHeader("Content-type", $sContentType)
|
|
'AddHeader("Cache-control", "private")
|
|
|
|
IF $bBuffered THEN
|
|
|
|
$hFile = OPEN Temp$("response") FOR CREATE
|
|
OUTPUT TO #$hFile
|
|
|
|
ELSE
|
|
|
|
PRINT $sHeader
|
|
|
|
ENDIF
|
|
|
|
$bBegin = TRUE
|
|
|
|
END
|
|
|
|
PUBLIC SUB End()
|
|
|
|
DIM sBuffer AS String
|
|
|
|
IF $bBuffered THEN
|
|
|
|
CLOSE #$hFile
|
|
OUTPUT TO DEFAULT
|
|
|
|
$hFile = OPEN Temp$("response") FOR READ
|
|
AddHeader("Content-Length", Lof($hFile))
|
|
|
|
PRINT $sHeader
|
|
|
|
WHILE NOT Eof($hFile)
|
|
READ #$hFile, sBuffer, -4096
|
|
PRINT sBuffer;
|
|
WEND
|
|
CLOSE #$hFile
|
|
|
|
ENDIF
|
|
|
|
END
|
|
|
|
PUBLIC SUB SendFile(Path AS String, OPTIONAL ContentType AS String)
|
|
|
|
DIM sBuffer AS String
|
|
|
|
IF NOT Exist(Path) THEN
|
|
PRINT "Status: 404 Not Found"
|
|
PRINT
|
|
RETURN
|
|
ENDIF
|
|
|
|
IF NOT ContentType THEN ContentType = $sContentType
|
|
PRINT "Content-type: "; ContentType
|
|
PRINT $sHeader;
|
|
'IF Name THEN PRINT "Content-location: "; "/" & CGI.Encode(Name)
|
|
|
|
$hFile = OPEN Path FOR READ
|
|
|
|
PRINT "Content-length: "; Lof($hFile)
|
|
PRINT
|
|
WHILE NOT Eof($hFile)
|
|
READ #$hFile, sBuffer, -4096
|
|
PRINT sBuffer;
|
|
WEND
|
|
CLOSE #$hFile
|
|
|
|
END
|
|
|
|
|
|
PRIVATE FUNCTION Buffered_Read() AS Boolean
|
|
|
|
RETURN $bBuffered
|
|
|
|
END
|
|
|
|
PRIVATE SUB Buffered_Write(Value AS Boolean)
|
|
|
|
$bBuffered = Value
|
|
|
|
END
|
|
|
|
PRIVATE FUNCTION ContentType_Read() AS String
|
|
|
|
RETURN $sContentType
|
|
|
|
END
|
|
|
|
PRIVATE SUB ContentType_Write(Value AS String)
|
|
|
|
$sContentType = Value
|
|
|
|
END
|
|
|
|
PRIVATE FUNCTION Status_Read() AS String
|
|
|
|
RETURN $sStatus
|
|
|
|
END
|
|
|
|
PRIVATE SUB Status_Write(Value AS String)
|
|
|
|
$sStatus = Value
|
|
|
|
END
|