mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
[ruby] fix: HEAD requests (#9436)
When WEBrick receives `HEAD` requests it discards the body (i.e. `req.body.nil? => true`), this causes Vercel to throw a `BODY_NOT_A_STRING_FROM_FUNCTION` since it is expecting the serverless function to respond with a string in the body. --------- Co-authored-by: Nathan Rajlich <n@n8.io> Co-authored-by: Steven <steven@ceriously.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"builds": [{ "src": "index.rb", "use": "@vercel/ruby" }],
|
"builds": [{ "src": "index.rb", "use": "@vercel/ruby" }],
|
||||||
"probes": [{ "path": "/", "mustContain": "gem:RANDOMNESS_PLACEHOLDER" }]
|
"probes": [
|
||||||
|
{ "path": "/", "mustContain": "gem:RANDOMNESS_PLACEHOLDER" },
|
||||||
|
{ "path": "/", "method": "HEAD", "status": 200 }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ def webrick_handler(httpMethod, path, body, headers)
|
|||||||
{
|
{
|
||||||
:statusCode => res.code.to_i,
|
:statusCode => res.code.to_i,
|
||||||
:headers => res_headers,
|
:headers => res_headers,
|
||||||
:body => res.body,
|
:body => res.body.nil? ? "" : res.body,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ async function fetchDeploymentUrl(url, opts) {
|
|||||||
for (let i = 0; i < 50; i += 1) {
|
for (let i = 0; i < 50; i += 1) {
|
||||||
const resp = await fetch(url, opts);
|
const resp = await fetch(url, opts);
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
if (text && !text.includes('Join Free')) {
|
if (typeof text !== 'undefined' && !text.includes('Join Free')) {
|
||||||
return { resp, text };
|
return { resp, text };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user