Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/maltefl/io
Browse files Browse the repository at this point in the history
  • Loading branch information
stevedekorte committed Apr 23, 2011
2 parents b139f1d + 4fc38d0 commit b4b7fff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions addons/HttpClient/io/HCConnection.io
Expand Up @@ -33,7 +33,7 @@ HCConnection := Object clone do(
if(request port asString == "80",
request setHeader("Host", request host)
,
request setHeader("Host", Sequence with(request host, ":", request port))
request setHeader("Host", Sequence with(request host, ":", request port asString))
)

request headers select(k, v, v != nil) map(k, v,
Expand All @@ -42,7 +42,7 @@ HCConnection := Object clone do(
)

httpMessage := method(
Sequence with(statusLine, headersLines, headerTerminator)
Sequence with(statusLine, headersLines, headerTerminator, request body)
)

sendMessage := method(
Expand Down Expand Up @@ -75,4 +75,4 @@ HCConnection := Object clone do(

self
)
)
)
22 changes: 20 additions & 2 deletions addons/HttpClient/io/HCRequest.io
Expand Up @@ -12,7 +12,8 @@
//doc HCRequest hasHeader(name) Returns true if this request has a header with name
//doc HCRequest setHeader(name, value) Sets header with name to value
//doc HCRequest headerAt(name) Returns the value for header with name

// doc HCRequest setBody(string) Sets the body to string and changes the "Content-Length" header accordingly
// doc HCReqeust body The message body

HCRequest := Object clone do(
url ::= nil
Expand All @@ -26,6 +27,8 @@ HCRequest := Object clone do(
headers atPut("Connection", "close")
)

messageBody ::= nil

with := method(url,
self clone setUrl(url)
)
Expand Down Expand Up @@ -57,4 +60,19 @@ HCRequest := Object clone do(
headerAt := method(name,
headers at(name)
)
)

setBody := method(string,
messageBody := string
if(messageBody isNil,
headers removeAt("Content-Length")
return
)

setHeader("Content-Length", messageBody size asString)
)

body := method(
messageBody ifNilEval(return "")
return messageBody
)
)

0 comments on commit b4b7fff

Please sign in to comment.