[Seaside] requestContext and extra data in the output

Brian Tabone brian.tabone at gmail.com
Mon Nov 22 21:19:34 UTC 2010


My question is about extra data I am seeing when using the
requestContext to send back JSon data for a web service.

I am using Seaside 3.0 in Pharo 1.1

My renderContentOn:html method is:

renderContentOn: html
	| resultDictionary |
	self requestContext
		respond: [:response |
			resultDictionary := Dictionary new.
			createError isNil
				ifTrue: [resultDictionary at: #listName put: listName.
					resultDictionary at: #listUUID put: todoList uuid asString]
				ifFalse: [resultDictionary at: #error put: createError class asString.
					resultDictionary at: #reason put: createError asString].
			response contentType: 'application/json'.
			response nextPutAll: resultDictionary asJson].

When I call the url for this web service, I get (here is the verbose
output from curl)

curl -v http://localhost:8081/createList
* About to connect() to localhost port 8081 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8081 (#0)
> GET /createList HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: localhost:8081
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 22 Nov 2010 21:17:48 GMT
< Connection: close
< Server: KomHttpServer/7.1.3 (Mac OS)
< Content-type: application/json
< Content-length: 465
<
* Closing connection #0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"><head><title>Seaside</title><meta http-equiv="Content-Type"
content="text/html;charset=utf-8"/><meta
http-equiv="Content-Script-Type"
content="text/javascript"/></head><body
onload="onLoad()">{"reason":"MessageNotUnderstood: receiver of
\"asSymbol\" is nil","error":"MessageNotUnderstood"}

Long story short, How do I get rid of the <html header data that is in
the buffer before I get a hold of the response to put my JSon data in
the stream? Should I re-initialize the response with a fresh buffer?

Thanks in advance,
Brian


More information about the seaside mailing list