# Creating an HTTPResponse manually

**URL:** <https://www.ruby-forum.com/t/creating-an-httpresponse-manually/166023>\
**Category:** Ruby\
**Created:** [April 21, 2009, 4:51am UTC](https://www.ruby-forum.com/t/creating-an-httpresponse-manually/166023 "2009-04-21T04:51:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryan82](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a87d85/32.png) [@bryan82](https://www.ruby-forum.com/u/bryan82)\
**Post date:** [April 21, 2009, 4:51am UTC](https://www.ruby-forum.com/t/creating-an-httpresponse-manually/166023/1 "2009-04-21T04:51:16Z")

</div>

I’m working on an application that reaches out to a web service. I’d  
like to develop a proxy class that returns a fake response from the  
service, so I don’t have to constantly be hitting it with requests while  
I’m developing/testing other parts of the app.

My application is expecting a response generated via Net::HTTP.

```
 response = Net::HTTP.get(URI.parse('http://foo.com'))

 case response
 when Net::HTTPOK
   # do something fun

 when Net::HTTPUnauthorized
   # you get the idea

```

How can I manufacture a response object, give it all the right headers,  
return a body string, etc? I assumed I need to use Net::HTTPResponse,  
but I can’t find any documentation on creating an instance without going  
through a request.

I’d like it to work like this:

```
 response = ProxyClass.response_object

 case response
 when Net::HTTPOk
   # my app doesn't know it's being lied to

```

Thanks.
