class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response
end
def on_load
set_nav_bar_button :left, title: "Menu", action: :nav_left_button
end
def load_started
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
end
def nav_left_button
app_delegate.menu.show(:left)
end
end
我需要发送带有特定标头的HTTP请求,但内容总是为零。我已经通过嗅探器检查了响应 - 一切都很好。
如果我这样做
class WorkoutScreen < PM::WebScreen
title "Workouts"
def content
@response = ''
BubbleWrap::HTTP.get("my_url", {async: false, :headers => { "User-Agent" => "value"}}) do |response|
@response = response.body.to_str
end
@response
end
我看到了
eb_screen_module.rb:50:在`set_content:':目录 - 读取()失败(Errno :: EISDIR)
例外
答案 0 :(得分:1)
NSUserDefaults.standardUserDefaults.registerDefaults({UserAgent: "value"})
自己找到解决方案