Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
c4605
@bolasblack
Member
NO. 14449 / 2014-08-11

番茄土豆
杭州
4 Topics / 15 Replies
0 Followers
0 Following
1 Favorites
GitHub Public Repos
  • BlogPosts 8

  • dotfiles 4

    dotfiles

  • js-metarepo 3

    A metarepo inspired from [nextools/metarepo](https://github.com/nextools/metarepo)

  • .emacsrc 3

    config of emacs

  • react-components 2

    Some useful react components.

  • babel-plugin-jsx-wrapper 2

    Babel plugin to wrap jsx arrow functions

  • BlogFront 2

  • c4g 1

    My schematics

  • LaunchBar 1

  • angular-cli 1

    CLI tool for Angular

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • Ruby post 发送 form-data 数据 at June 08, 2015

    其实它的接口说的挺清楚的,就是 Content-Type 不对,你自己发起请求的时候设置了这个头为 application/json ,所以接口认为你不是 post 了一个表单,就告诉你 415 不支持这种请求体的数据格式。当然普通表单的 Content-Type 是 application/x-www-form-urlencoded ,不是 multipart/form-data ,也是不对的 Orz,在普通浏览器里只有附带文件的时候 Content-Type 才会变成 multipart/form-data ,我怀疑 Net::HTTP 本身的逻辑也是这样子的;也不建议你自己把 Content-Type 设置为 multipart/form-data ,因为其实它的格式是这样子的:

    Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryrGKCBY7qhFd3TrwA
    
    ------WebKitFormBoundaryrGKCBY7qhFd3TrwA
    Content-Disposition: form-data; name="text"
    
    title
    ------WebKitFormBoundaryrGKCBY7qhFd3TrwA
    Content-Disposition: form-data; name="file"; filename="chrome.png"
    Content-Type: image/png
    
    PNG ... content of chrome.png ...
    ------WebKitFormBoundaryrGKCBY7qhFd3TrwA--
    

    所以当然 @rei 的方案应该是比较好的。

    以及,这个接口确实是奇葩接口,你不用觉得沮丧。原因就是我上面说的,如果真的是要求以 form 形式提交的话,不支持 application/x-www-form-urlencoded 是不对的。

  • 测试 Gem 的时候如何让 require 'path/filename' 优先载入项目文件? at February 09, 2015

    #5 楼 @suffering 嗯……经过 @Rei 的提示以后我才想到要去调整 Ruby 的加载路径列表……

    非常谢谢你回答我!

  • 测试 Gem 的时候如何让 require 'path/filename' 优先载入项目文件? at February 09, 2015

    #2 楼 @Rei 啊,谢谢你!成功了!

  • 测试 Gem 的时候如何让 require 'path/filename' 优先载入项目文件? at February 09, 2015

    #1 楼 @liprais 我修改了那个类的文件的代码,但除非我 gem build 然后 gem install,否则单元测试里 require 到的这个类就不会有我增加的方法

  • 当 self.attr.nil? 时 self.attr ||= 和 self.attr = 的区别 at October 30, 2014

    #5 楼 @serco 原来真的是这样子……太谢谢你了……

  • 当 self.attr.nil? 时 self.attr ||= 和 self.attr = 的区别 at October 29, 2014

    自己顶一下,找了不少资料似乎都没有这方面的说法,求大家为我解释一下……

  • 当 self.attr.nil? 时 self.attr ||= 和 self.attr = 的区别 at October 29, 2014

    #2 楼 @davidqhr 难道 initialize 里的代码不是在类内的吗?为什么在 initialize 里使用 self.a ||= 1 也会报错?

  • bundle exec 非常慢 at October 14, 2014

    很奇怪,重新克隆下来 bundle install 后就不慢了……

  • 交互式 rebase at September 22, 2014

    #6 楼 @hiveer 关于在 rebase -i 里使用 origin/master 和 HEAD~2 的区别

    首先不论是 origin/master 还是 HEAD~2 其实都是某个 commit 的 sha1 的别名, origin/master 就是那个名叫 origin 的 remote 里的 master 分支所指向的 sha1,而 HEAD~2 就是比当前工作环境所在的 commit 早两个历史的 commit 的 sha1

  • 交互式 rebase at September 22, 2014

    #6 楼 @hiveer

    git rebase -i 是没法包含历史上的第一次 commit 的,所以就报了这个错,如果你做到这个的话可以这么干:

    git reset HEAD~2 git add -A git commit --amend

  • 《Ruby on Rails 教程 (第二版)》最后的折扣 at September 02, 2014

    #13 楼 @andor_chen 那我只买了其中的 epub 版本呢?会收到优惠码吗?

  • [已解决] HTML5 中 audio 的 duration 无法正常使用怎么办? at August 23, 2014

    #6 楼 @chairy11 我这里的情况比较复杂,那些 js 库基本没法帮我……

  • [已解决] HTML5 中 audio 的 duration 无法正常使用怎么办? at August 23, 2014

    @chairy11 各大浏览器实现 audio 的时候似乎 bug 很多,我最近也被这东西坑的死去活来的 ^_^

  • [已解决] HTML5 中 audio 的 duration 无法正常使用怎么办? at August 22, 2014

    你试试监听事件 canplaythrough ,我获得 duration 监听的都是这个事件

关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English