Comments (4)
For now I was able to circumvent the problem with a pretty ugly solution. I parse the response in a protected call, and if I get an error, I use string.match() to find the error code within the error message. Unfortunately the error message changes for codes 404 and 410, leaving no information on which of those two error codes was received. Since 404 is way more frequent, I decided to return 404 in that situation.
Of course a fix would be better.
function requestWithResponseCode(url, post_data, headers, method)
local handle = internet.request(url, post_data, headers, method)
local result = ""
local success, error = pcall(function() for chunk in handle do result = result..chunk end end)
if success == false and error ~= nil then
local error_code = error:match("code: (%d%d%d) ")
if error_code ~= nil then
return error_code, result
else
return 404, result
end
end
if success == true then
local mt = getmetatable(handle)
local code, message, headers = mt.__index.response()
return code, result
end
end
from opencomputers.
It was fixed, but then it was reverted as not every Minecraft configuration actually had the Apache HTTP client library, nor could I figure out in the limited maintenance time I have for the mod: 555ae0e
from opencomputers.
The problem, I suppose, is that:
- a bunch of programs (like wget) depend on the old behaviour to some extent (they don't check the response code at all, assuming exception = failure),
- reading the response code requires a relatively unintuitive
while not response.finishConnect() do os.sleep(0.05) end ; local code, message = response.response()
call, and should probably get a friendlier API.
So this would best go into an OpenComputers 1.9.0 update; but given the mod is essentially unmaintained...
from opencomputers.
@kodai2199 Hopefully this workaround will be to your satisfaction, for the time being.
from opencomputers.
Related Issues (20)
- Coroutine.wrap does not propagate errors raised in a coroutine HOT 1
- Build server (ci.cil.li) down HOT 1
- Error when trying to boot the Mine os system HOT 3
- Adoption of Teal/EmmyLua typing anotation
- Draconic Evolution sword + robot.swing()
- (Non-issue) How do you achieve lua in minecraft? HOT 2
- Blocks from different mods got messed up after crash HOT 1
- OPPM fails to install HOT 16
- the internet card gives issues whit oppm end irc chat but not whit wget HOT 1
- the internet card gives issues whit oppm end irc chat but not whit wget HOT 1
- error installing mine os HOT 1
- Potential memory leak
- The future of OpenComputers 1? HOT 3
- Missing translation after v1.8.4
- downloading files from github is not working for you HOT 1
- Error URL parsing when oppm install package
- Event API - timeout ignores filters HOT 1
- Wireless Redstone `getWirelessInput` method broken (since 2014!)
- FIX GITHUB!!!!!!!!!!! HOT 4
- server freezes during internet card timeout
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencomputers.