Jump to content




HTTP Enhancements


  • You cannot reply to this topic
31 replies to this topic

#1 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 April 2015 - 09:01 AM

Firstly I would love to see the ability to get the http header from the response, we have the ability to set the header, why don't we have the ability to read the header too? It could open up a world of more advanced clients with the likes of GitHub and such.

Secondly I would love to see more HTTP Request Methods. I have a few RESTful APIs that I wish to use that make use of GET, POST, PUT, and DELETE; I would also like to make my own APIs which use these for some upcoming projects. The current implementation of the http api doesn't not allow anything other than GET and POST. I feel like it shouldn't be too difficult given the recent changes in CC for you to add in Java-side the http.put and http.delete in addition to the existing http.get and http.post. Having PATCH might be useful as well for some RESTful APIs, however it is a little less commonly used.

#2 ElvishJerricco

  • Members
  • 803 posts

Posted 12 April 2015 - 09:40 AM

Binary mode would also be sweet.

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 April 2015 - 10:03 AM

well the LuaJ bug hinders that a little.

#4 ElvishJerricco

  • Members
  • 803 posts

Posted 12 April 2015 - 10:07 AM

View Posttheoriginalbit, on 12 April 2015 - 10:03 AM, said:

well the LuaJ bug hinders that a little.

Not if gone the way of file IO's binary handling, where reading returns numbers instead of strings.

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 April 2015 - 10:33 AM

This is true

#6 SeaLife

  • Members
  • 23 posts

Posted 16 April 2015 - 06:53 PM

This would be very helpful to play with the GitLab Api :)

Cause it returns 401 http-codes with text which i need to use... (Like: {"message": "No Permitted"})

http.get( url ), http.post( url ) and http.return( ) should always return an Object

* Header (With the Code and so on...)
* Content (Even 404-Messages)


Or an mode?

http.enhanced( true ) - And now it should work? :D (Just a little idea to keep the old "api" for all old programs)



+1

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 17 April 2015 - 03:45 AM

View PostSeaLife, on 16 April 2015 - 06:53 PM, said:

http.enhanced( true ) - And now it should work? :D (Just a little idea to keep the old "api" for all old programs)
well the idea that I have would still allow old programs to work as there would just be extra methods on the HTTP API, and more methods on their result.

#8 SeaLife

  • Members
  • 23 posts

Posted 17 April 2015 - 08:26 PM

mhh...

the problem is, now the program check with "if h then" (h = http.get(url))

but now, everytime (even if the answer is 404), "h" would contain functions... "if not h then" would never happen then (eq. to "if h then" would always be true)

if enhanced mode is off, it'll return "nil" ohn failure.. like now...

with enhanced on, it should always return something.. like h.getResponseCode() (404, 201, 401, 403, ...) (even on failure, because it is not real a failure :D)

#9 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 18 April 2015 - 12:16 PM

View PostSeaLife, on 17 April 2015 - 08:26 PM, said:

mhh...

the problem is, now the program check with "if h then" (h = http.get(url))

but now, everytime (even if the answer is 404), "h" would contain functions... "if not h then" would never happen then (eq. to "if h then" would always be true)

if enhanced mode is off, it'll return "nil" ohn failure.. like now...

with enhanced on, it should always return something.. like h.getResponseCode() (404, 201, 401, 403, ...) (even on failure, because it is not real a failure :D)

Then there could be a function like hasFailed() to check if an error happened.

#10 flaghacker

  • Members
  • 655 posts

Posted 18 April 2015 - 02:43 PM

View PostFreack100, on 18 April 2015 - 12:16 PM, said:

View PostSeaLife, on 17 April 2015 - 08:26 PM, said:

mhh...

the problem is, now the program check with "if h then" (h = http.get(url))

but now, everytime (even if the answer is 404), "h" would contain functions... "if not h then" would never happen then (eq. to "if h then" would always be true)

if enhanced mode is off, it'll return "nil" ohn failure.. like now...

with enhanced on, it should always return something.. like h.getResponseCode() (404, 201, 401, 403, ...) (even on failure, because it is not real a failure :D/>)

Then there could be a function like hasFailed() to check if an error happened.

That would still break backwards compatibility.

#11 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 18 April 2015 - 03:07 PM

View Postflaghacker, on 18 April 2015 - 02:43 PM, said:

View PostFreack100, on 18 April 2015 - 12:16 PM, said:

View PostSeaLife, on 17 April 2015 - 08:26 PM, said:

mhh...

the problem is, now the program check with "if h then" (h = http.get(url))

but now, everytime (even if the answer is 404), "h" would contain functions... "if not h then" would never happen then (eq. to "if h then" would always be true)

if enhanced mode is off, it'll return "nil" ohn failure.. like now...

with enhanced on, it should always return something.. like h.getResponseCode() (404, 201, 401, 403, ...) (even on failure, because it is not real a failure :D/>)

Then there could be a function like hasFailed() to check if an error happened.

That would still break backwards compatibility.

Yes, it would break backward compatibility. But it won't be a big problem to update a program to these new "standards".

#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 April 2015 - 12:26 AM

View PostFreack100, on 18 April 2015 - 03:07 PM, said:

View Postflaghacker, on 18 April 2015 - 02:43 PM, said:

That would still break backwards compatibility.

Yes, it would break backward compatibility. But it won't be a big problem to update a program to these new "standards".
The other thing to remember, Dan is going to move over to Lua 5.2, that will break a lot of programs.

#13 flaghacker

  • Members
  • 655 posts

Posted 19 April 2015 - 06:55 AM

View Posttheoriginalbit, on 19 April 2015 - 12:26 AM, said:

View PostFreack100, on 18 April 2015 - 03:07 PM, said:

The other thing to remember, Dan is going to move over to Lua 5.2, that will break a lot of programs.

Is he? I thought he didn't want to do that?

#14 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 19 April 2015 - 07:05 AM

http://www.computerc...post__p__213124

#15 flaghacker

  • Members
  • 655 posts

Posted 19 April 2015 - 08:41 AM

View PostBomb Bloke, on 19 April 2015 - 07:05 AM, said:


Nice!

#16 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 20 April 2015 - 07:41 PM

View Postflaghacker, on 18 April 2015 - 02:43 PM, said:

That would still break backwards compatibility.
What about adding a xhttp API which allows you to do everything that is possible in the web, and modify the http API so it's just a simple wrapper around the xhttp API?

#17 SeaLife

  • Members
  • 23 posts

Posted 21 April 2015 - 03:54 PM

View Postardera, on 20 April 2015 - 07:41 PM, said:

View Postflaghacker, on 18 April 2015 - 02:43 PM, said:

That would still break backwards compatibility.
What about adding a xhttp API which allows you to do everything that is possible in the web, and modify the http API so it's just a simple wrapper around the xhttp API?

seems legit...

i like the idea...

it would help me to use JIRA RestAPI and some other POST (with Json) apis...
For Jira (e.g.) you've to edit the Header to send: Content-Type: application/json

if xhttp would make this possible, i will fall in love with @dan200 :D


(Sorry for this bad english... im from Germany :I )

#18 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 21 April 2015 - 05:09 PM

View PostSeaLife, on 21 April 2015 - 03:54 PM, said:

For Jira (e.g.) you've to edit the Header to send: Content-Type: application/json

You can already send request headers. What you cannot do is get response headers.

#19 SeaLife

  • Members
  • 23 posts

Posted 22 April 2015 - 04:38 PM

View PostMKlegoman357, on 21 April 2015 - 05:09 PM, said:

View PostSeaLife, on 21 April 2015 - 03:54 PM, said:

For Jira (e.g.) you've to edit the Header to send: Content-Type: application/json

You can already send request headers. What you cannot do is get response headers.

Seems legit...

#20 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 April 2015 - 11:31 PM

View PostSeaLife, on 22 April 2015 - 04:38 PM, said:

-snip-
HTTP API, take note of the optional header argument





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users