Silent failure when staticPaths points to a file instead of a directory

未关闭
#267 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
c, r
领域
backend

调研方向

Start with the staticPaths and staticPathOptions handling used by startServer, then reproduce the /foo/bar request with the example app and curl. Determine how a file-valued static path is handled, and make the behavior report an explicit error instead of failing silently; verify the request no longer produces an unexplained 500.

由索引模型根据 Issue 内容生成。

描述

Given this app:

app <- list(
  call = function(req) {
    list(status = 404L,
         headers = list('Content-Type' = 'text/plain'),
         body = "Not found")
  },
  staticPaths = list(
    "/foo" = "foo.html"
  ),
  staticPathOptions = staticPathOptions(fallthrough = TRUE)
)
s <- startServer('127.0.0.1', 31337, app)

Any attempts to fetch a subpath under /foo will fail silently:

$ curl -v http://localhost:31337/foo/bar
*   Trying 127.0.0.1:31337...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 31337 (#0)
> GET /foo/bar HTTP/1.1
> Host: localhost:31337
> User-Agent: curl/7.66.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Fri, 08 May 2020 02:20:02 GMT
< Content-Length: 26
< 
500 Internal Server Error
* Connection #0 to host localhost left intact

There is no error in the R console when this request is made.

This may not be a bug per se, but if specifying a file instead of a directory in staticPaths is not allowed, I would have expected some sort of error telling me so. Let me know if I can provide any further information.

主要语言
C
星标
252
派生
87
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rstudio/httpuv 的其他 Issue

查看 rstudio/httpuv 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。