Skip to content

Commit

Permalink
throw error if method is head and sending a body
Browse files Browse the repository at this point in the history
  • Loading branch information
tikotzky committed Feb 15, 2015
1 parent 1f895d5 commit d6c911d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions index.js
Expand Up @@ -47,6 +47,10 @@ function request (uri, options, callback) {
options.callback = params.callback
options.uri = params.uri

if (params.options.method === 'HEAD' && paramsHaveRequestBody(params)) {
throw new Error('HTTP HEAD requests MUST NOT include a request body.')
}

return new request.Request(options)
}

Expand All @@ -66,11 +70,6 @@ request.get = function (uri, options, callback) {
request.head = function (uri, options, callback) {
var params = initParams(uri, options, callback)
params.options.method = 'HEAD'

if (paramsHaveRequestBody(params)) {
throw new Error('HTTP HEAD requests MUST NOT include a request body.')
}

return requester(params)(params.uri || null, params.options, params.callback)
}

Expand Down

0 comments on commit d6c911d

Please sign in to comment.