Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
6b234bdc
Verified
Commit
6b234bdc
authored
Jan 10, 2017
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Internet.HTTP.CGI (fixes
#3
)
parent
dba91cb7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
+22
-5
src/libraries/OS-Independent/Internet/HTTP.dcl
src/libraries/OS-Independent/Internet/HTTP.dcl
+1
-2
src/libraries/OS-Independent/Internet/HTTP.icl
src/libraries/OS-Independent/Internet/HTTP.icl
+18
-0
src/libraries/OS-Independent/Internet/HTTP/CGI.icl
src/libraries/OS-Independent/Internet/HTTP/CGI.icl
+2
-2
tests/linux64/test.icl
tests/linux64/test.icl
+1
-1
No files found.
src/libraries/OS-Independent/Internet/HTTP.dcl
View file @
6b234bdc
...
...
@@ -98,5 +98,4 @@ badRequestResponse :: !String -> HTTPResponse
staticResponse
::
!
HTTPRequest
!*
World
->
(!
HTTPResponse
,
!*
World
)
customResponse
::
![((
String
->
Bool
),(
HTTPRequest
*
World
->
(
HTTPResponse
,
*
World
)))]
!
Bool
!
HTTPRequest
!*
World
->
(!
HTTPResponse
,
!*
World
)
encodeResponse
::
!
Bool
!
HTTPResponse
!*
World
->
(!
String
,!*
World
)
src/libraries/OS-Independent/Internet/HTTP.icl
View file @
6b234bdc
...
...
@@ -283,3 +283,21 @@ customResponse [(pred,handler):rest] fallback request world
=
handler
request
world
//Apply handler function
=
customResponse
rest
fallback
request
world
//Search the rest of the list
//Response utilities
encodeResponse
::
!
Bool
!
HTTPResponse
!*
World
->
(!
String
,!*
World
)
encodeResponse
withreply
{
rsp_headers
=
headers
,
rsp_data
=
data
}
world
#
reply
=
if
withreply
(
"HTTP/1.0 "
+++
(
default
"200 OK"
(
lookup
"Status"
headers
))
+++
"
\r\n
"
)
(
"Status: "
+++
(
default
"200 OK"
(
lookup
"Status"
headers
))
+++
"
\r\n
"
)
#
reply
=
reply
+++
(
"Server: "
+++
(
default
"Clean HTTP tools"
(
lookup
"Server"
headers
))
+++
"
\r\n
"
)
//Server identifier
#
reply
=
reply
+++
(
"Content-Type: "
+++
(
default
"text/html"
(
lookup
"Content-Type"
headers
))
+++
"
\r\n
"
)
//Content type header
#
reply
=
reply
+++
(
"Content-Length: "
+++
(
toString
(
size
data
))
+++
"
\r\n
"
)
//Content length header
#
reply
=
reply
+++
(
foldr
(+++)
""
[(
n
+++
": "
+++
v
+++
"
\r\n
"
)
\\
(
n
,
v
)
<-
headers
|
not
(
skipHeader
n
)])
//Additional headers
#
reply
=
reply
+++
(
"
\r\n
"
+++
data
)
//Separator + data
=
(
reply
,
world
)
where
//Do not add these headers two times
default
def
mbval
=
case
mbval
of
Nothing
=
def
(
Just
val
)
=
val
skipHeader
s
=
isMember
s
[
"Status"
,
"Date"
,
"Server"
,
"Content-Type"
,
"Content-Length"
,
"Last-Modified"
]
src/libraries/OS-Independent/Internet/HTTP/CGI.icl
View file @
6b234bdc
implementation
module
Internet
.
HTTP
.
CGI
import
StdFile
,
StdInt
,
StdBool
,
StdArray
import
Data
.
Maybe
,
Internet
.
HTTP
,
Text
,
System
.
Environment
,
Data
.
Map
import
Data
.
Maybe
,
Data
.
Tuple
,
Internet
.
HTTP
,
Text
,
System
.
Environment
,
Data
.
Map
//Http headers which should be polled in the environment
CGI_HEADERS
:==
[
(
"Content-Type"
,
"CONTENT_TYPE"
)
...
...
@@ -22,7 +22,7 @@ startCGI options handlers world
#
(
ok
,
console
)
=
freopen
console
FReadData
#
(
datalength
,
world
)
=
getDataLength
world
#
(
data
,
console
)
=
getData
datalength
console
//Read post data
#
(
req_method
,
world
)
=
getFromEnv
"REQUEST_METHOD"
world
//Read environment data
#
(
req_method
,
world
)
=
appFst
fromString
(
getFromEnv
"REQUEST_METHOD"
world
)
//Read environment data
#
(
req_path
,
world
)
=
getFromEnv
"SCRIPT_NAME"
world
#
(
req_query
,
world
)
=
getFromEnv
"QUERY_STRING"
world
#
(
req_version
,
world
)
=
getFromEnv
"SERVER_PROTOCOL"
world
...
...
tests/linux64/test.icl
View file @
6b234bdc
...
...
@@ -92,6 +92,7 @@ import qualified Graphics.Layout
import
qualified
Graphics
.
Scalable
import
qualified
Graphics
.
Scalable
.
Internal
import
qualified
Internet
.
HTTP
import
qualified
Internet
.
HTTP
.
CGI
import
qualified
Math
.
Geometry
import
qualified
Math
.
Random
import
qualified
Network
.
IP
...
...
@@ -138,7 +139,6 @@ import qualified Text.Unicode.UChar
//Errors that need to be fixed
import
qualified
Text
.
XML
import
qualified
Internet
.
HTTP
.
CGI
import
qualified
Database
.
SQL
.
RelationalMapping
Start
=
"Hello World!"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment