Skip to content

Instantly share code, notes, and snippets.

@MichaelXavier
Created May 12, 2013 18:00
Show Gist options
  • Save MichaelXavier/5564392 to your computer and use it in GitHub Desktop.
Save MichaelXavier/5564392 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'pp'
delete '/' do
"you DELETED: #{request.body.string}"
end
put '/' do
"you PUTTED: #{request.body.string}"
end
{-# LANGUAGE OverloadedStrings #-}
import System.IO.Streams (InputStream, OutputStream, stdout)
import qualified System.IO.Streams as Streams
import qualified Data.ByteString as S
import Network.Http.Client
main :: IO ()
main = do
withConnection (openConnection "localhost" 4567) $ \c -> do
stream <- Streams.fromLazyByteString "SERVER SHOULD GET THIS BODY"
q <- buildRequest $ do
http DELETE "/" -- no body gets sent
--http PUT "/" -- body gets sent
setAccept "text/html"
sendRequest c q $ inputStreamBody stream
receiveResponse c debugHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment