Skip to content

Headers should be defaulted #36

Open

Description

@samyakbhuta

https://github.com/LearnBoost/tobi/blob/master/lib/browser.js#L130

Currently there is no way the header's are defaulted. Guess it would be nice that there is a way to set some headers that are anyway expected by many of the server side code (e.g. express.js) like already done at https://github.com/LearnBoost/tobi/blob/master/lib/browser.js#L158. The other day tobi simulated POST request couldn't find req.body in the express.js middleware as headers['Content-type'] = 'application/json'; was missing.

Also, neither README nor the blogpost like this http://vilimpoc.org/blog/2011/01/19/testing-rest-api-with-learnboosts-tobi-vows-js/ specifies such necessity of setting the headers.

Activity

  1. tj commented on Jun 7, 2011

    @tj
    Contributor

    browser.get('/login', { headers: { ... }}, function(res, $){ etc. how would you expect them to be defaulted? you want it to guess that it's json? not sure I get what you mean

  2. tastapod commented on Jun 14, 2011

    @tastapod

    It's easy enough in an explicit browser.get or browser.post to set headers, but I can't set headers in the GET that occurs on a browser.click, for instance.

    I'd like to be able to default the browser to always send Accept: text/html (unless I explicitly override it in an individual GET) but right now I can't.

  3. hudgins commented on Jan 5, 2012

    @hudgins

    Similarly, you can't set the headers for a POST that happens as the result of a $('form').submit(). I'm using tobi with a system that creates a separate set of database tables namespaced by the virtual host. In testing on localhost, I set the host header to 'test' for each call to take advantage of this and segregate the test data. Works, except for the POST on submit(). What's the right solution here? Carry the host header in a browser.get/post/etc on to any subsequent requests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions