GithubHelp home page GithubHelp logo

reqn's Introduction

Reqn

Pronounced /ˈɹɛkən/, like "reckon".

Reqn is an HTTP request library for Skript 2.X.

Syntax

Effect Send Web Request

Submits an HTTP request to the given URL. This

Syntax

send [a[n]] [http] [%method%] [web] request to [the] [url] %url% [with ([the] header[s] %headers% [and [the] body %body%]|[the] body %body% [and [the] header[s] %headers%])]

The last part of the syntax simply allows the header and body to be written in either order (e.g. with the headers and the body or with the body and the headers)

Parameters

  • method (type text) - The HTTP method to use to send the request. If omitted, defaults to "get".
  • url (type text) - The URL to send the request to.
  • headers (type texts) - One or more headers in the format "Header-Name: Value" to be sent in the request header.
  • body (type texts) - Additional data to be sent in the body of the request. Multiple texts are joined with new lines. This cannot be sent if the request uses the "get" method.

Expression Last Response => httpresponse

Returns a custom httpresponse object that contains information from the last completed http request.

Syntax

[the] [last[ly]] [received] [http] [web] response


Expression Response Code => number

Returns the status codes of one or more httpresponses.

Syntax

[the] [response] [status] code[s] of %httpresponses% or %httpresponses%'[s] [response] [status] code[s]


Expression Response Message => text

Returns the status messages of one or more httpresponses.

Syntax

[the] [response] [status] (message|reason)[s] of %httpresponses% or %httpresponses%'[s] [response] [status] (message|reason)[s]


Expression Response Status => text

Returns the status lines of one or more httpresponses.

Syntax

[the] [response] status[(es| line[s])] of %httpresponses% or %httpresponses%'[s] [response] status[(es| line[s])]


Expression Response Headers => texts

Returns the headers of one or more httpresponses in the format "Header-Name: Value".

Multiple httpresponses may be passed to this expression, but the resulting headers will be combined into a single list with no way to associate each header with its original httpresponse.

Syntax

[the] [response] header[s] of %httpresponses% or %httpresponses%'[s] [response] header[s]


Expression Response Header Keys => texts

Returns the header keys (names) of one or more httpresponses. This expression is best used in conjunction with Response Header Values

Multiple httpresponses may be passed to this expression, but the resulting keys will be combined into a single list with no way to associate each key with its original httpresponse.

Syntax

[the] [response] header key[s] of %httpresponses% or %httpresponses%'[s] [response] header key[s]


Expression Response Header Values => texts

Returns the header values of one or more httpresponses. This expression is best used in conjunction with Response Header Keys

Multiple httpresponses may be passed to this expression, but the resulting values will be combined into a single list with no way to associate each value with its original httpresponse.

Syntax

[the] [response] header value[s] of %httpresponses% or %httpresponses%'[s] [response] header value[s]


Expression Specific Response Header Value => text

Returns the values of a specific header for one or more httpresponses.

Multiple httpresponses may be passed to this expression, but the resulting values will be combined into a single list with no way to associate each value with its original httpresponse.

Syntax

[the] %header% [response] header[ value][s] of %httpresponses% or %httpresponses%'[s] %header% [response] header[ value][s]

Parameters

  • header (type text) - The name of the header to return.

Expression Response Body => text

Returns the bodies of one or more httpresponses.

Syntax

[the] [response] bod(y|ies) of %httpresponses% or %httpresponses%'[s] [response] bod(y|ies)


Expression URL Safe Text => text

Converts a text into a text safe for usage in URLs. This can be useful for injecting user input into a URL (e.g. when using a search api).

Syntax

(http|ur(i|l)) (safe|encoded|escaped) %input%

Parameters

  • input (type texts) - One or more input texts to encode.

Expression JSON Safe Text => text

Converts a text into a text safe for usage in JSON strings. This can be useful for injecting user input into a JSON payload (e.g. when using a search api).

Syntax

json (safe|encoded|escaped) %input%

Parameters

  • input (type texts) - One or more input texts to encode.

Contributing

Feel free to submit pull requests, just make sure your changes are consistent with Google's Java code style!

reqn's People

Contributors

btk5h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

reqn's Issues

Requesting a fake link generates code 401 that breaks reqn

01.09 01:35:46 [Server] pool-17-thread-3/WARN java.io.IOException: Server returned HTTP response code: 401 for URL: https://dl.dropboxusercontent.com/s/testurl/testing.mp3?dl=0

command /debug [<text>]:
  permission: skript.admin
  trigger:
    send an http "head" request to arg-1
    set {_resp} to the last http response
    wait 1 second
    set {_code} to {_resp}'s status code
    send {_code}

When using the command /debug https://dl.dropboxusercontent.com/s/testurl/testing.mp3?dl=0, instead of returning a http response to be checked, {_resp} and {_code} is not set, as reqn generates an error to the console.

Thanks.

Request is broken

I keep getting this as a response in my request help,

`

<title>Bad Request</title>

Bad Request

Invalid HTTP Version 'Invalid HTTP Version: 'Blue - Rise ft. Jack & Jack&text_only=no HTTP/1.0'' `

Status Code: 400

send a request to "https://api.ksoft.si/lyrics/search?q=Jonas Blue - Rise ft. Jack & Jack&text_only=no" with headers "User-Agent: Ender", "Content-Type: application/json" and "Authorization: Token ---" map json last response's body to {_lyricss::*}

Variable not working in or after

on death:
   victim is player:
        set {_Location} to location of victim
        broadcast "%{_Location}% 3"
        send a "post" request to ..............
        broadcast "%{_Location}% 4"```

"Broadcast 3" works but "Broadcast 4" doesnt and the variable inside the reqn also doesnt work just reports <none> when reqg commented it works.

reqn error

send a request to "http://localhost/index.php?test=123"

should that work? doesn't seem to 1.18.1 spigot latest

[01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! [Skript] Severe Error: [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Something went horribly wrong with Skript. [01:54:37] [Server thread/ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either. [01:54:37] [Server thread/ERROR]: #!#! It looks like you are using some plugin(s) that alter how Skript works (addons). [01:54:37] [Server thread/ERROR]: #!#! Following plugins are probably related to this error in some way: [01:54:37] [Server thread/ERROR]: #!#! WebSK [01:54:37] [Server thread/ERROR]: #!#! You should try disabling those plugins one by one, trying to find which one causes it. [01:54:37] [Server thread/ERROR]: #!#! If the error doesn't disappear even after disabling all listed plugins, it is probably Skript issue. [01:54:37] [Server thread/ERROR]: #!#! In that case, you will be given instruction on how should you report it. [01:54:37] [Server thread/ERROR]: #!#! On the other hand, if the error disappears when disabling some plugin, report it to author of that plugin. [01:54:37] [Server thread/ERROR]: #!#! Only if the author tells you to do so, report it to Skript's issue tracker. [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Stack trace: [01:54:37] [Server thread/ERROR]: #!#! java.lang.ClassCastException: class java.util.concurrent.ConcurrentHashMap cannot be cast to class java.util.HashMap (java.util.concurrent.ConcurrentHashMap and java.util.HashMap are in module java.base of loader 'bootstrap') [01:54:37] [Server thread/ERROR]: #!#! at com.btk5h.reqn.skript.EffRequest.execute(EffRequest.java:109) [01:54:37] [Server thread/ERROR]: #!#! at com.btk5h.reqn.skript.EffRequest.walk(EffRequest.java:139) [01:54:37] [Server thread/ERROR]: #!#! at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88) [01:54:37] [Server thread/ERROR]: #!#! at dev.jensderuiter.websk.web.Webserver.lambda$null$0(Webserver.java:83) [01:54:37] [Server thread/ERROR]: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftTask.run(CraftTask.java:82) [01:54:37] [Server thread/ERROR]: #!#! at org.bukkit.craftbukkit.v1_18_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:415) [01:54:37] [Server thread/ERROR]: #!#! at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1255) [01:54:37] [Server thread/ERROR]: #!#! at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:428) [01:54:37] [Server thread/ERROR]: #!#! at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1206) [01:54:37] [Server thread/ERROR]: #!#! at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1034) [01:54:37] [Server thread/ERROR]: #!#! at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) [01:54:37] [Server thread/ERROR]: #!#! at java.base/java.lang.Thread.run(Thread.java:833) [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Version Information: [01:54:37] [Server thread/ERROR]: #!#! Skript: 2.6.1 (latest) [01:54:37] [Server thread/ERROR]: #!#! Flavor: skriptlang-github [01:54:37] [Server thread/ERROR]: #!#! Date: 22:18:42.554713200 [01:54:37] [Server thread/ERROR]: #!#! Bukkit: 1.18.1-R0.1-SNAPSHOT [01:54:37] [Server thread/ERROR]: #!#! Minecraft: 1.18.1 [01:54:37] [Server thread/ERROR]: #!#! Java: 17.0.2 (OpenJDK 64-Bit Server VM 17.0.2+8) [01:54:37] [Server thread/ERROR]: #!#! OS: Windows 10 amd64 10.0 [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Server platform: Spigot [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Current node: null [01:54:37] [Server thread/ERROR]: #!#! Current item: send http request [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Thread: Server thread [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! Language: english [01:54:37] [Server thread/ERROR]: #!#! Link parse mode: DISABLED [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/ERROR]: #!#! End of Error. [01:54:37] [Server thread/ERROR]: #!#! [01:54:37] [Server thread/WARN]: [Skript] You are not returning anything from a web server request!

Request isn't sent and no error appears. Unsure what's happening

My code is below, nothing appears to send from the server and nothing is recieved on the other end.

`
command /auth:

trigger:

    set {_rnd} to random integer from 1 to 4096

    set {_prehash} to hashed "RST%player%RST%now%%{_rnd}%"

    set {_hash} to the first 12 characters of "%{_prehash}%"

    set {_name} to "%name of player%"

    set {_uuid} to the uuid of player

    set {_sname} to url safe {_name}

    set {_suuid} to url safe {_uuid}

    set {_shash} to url safe {_hash}

    set {_url} to "http://auth.redstonetor.ch/upload_details.php?n=%{_sname}%&u=%{_suuid}%&p=%{_shash}%"

    send request to {_url}

    message "Thanks for authenticating your Minecraft account %{_name}%!%nl%%nl%Your one time key is%nl%%nl%-[ &l%{_hash}%&r ]-%nl%%nl%Please enter this code into the key box.%nl%%{_url}%%nl%%{_temp}%"`

Issue with reqn/skript-json

[18:05:36 ERROR]:               java.util.WeakHashMap.get(WeakHashMap.java:403)
[18:05:36 ERROR]:               ch.njol.skript.variables.Variables.setVariable(Variables.java:352)
[18:05:36 ERROR]:               ch.njol.skript.lang.function.ScriptFunction.execute(ScriptFunction.java:84)
[18:05:36 ERROR]:               ch.njol.skript.lang.function.Function.execute(Function.java:119)
[18:05:36 ERROR]:               ch.njol.skript.lang.function.FunctionReference.execute(FunctionReference.java:204)
[18:05:36 ERROR]:               ch.njol.skript.lang.function.EffFunctionCall.execute(EffFunctionCall.java:53)
[18:05:36 ERROR]:               ch.njol.skript.lang.Effect.run(Effect.java:52)
[18:05:36 ERROR]:               ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[18:05:36 ERROR]:               ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[18:05:36 ERROR]:               ch.njol.skript.lang.Trigger.execute(Trigger.java:55)
[18:05:36 ERROR]:               ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:152)
[18:05:36 ERROR]:               ch.njol.skript.SkriptEventHandler$1.execute(SkriptEventHandler.java:110)
[18:05:36 ERROR]:               co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74)
[18:05:36 ERROR]:               org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[18:05:36 ERROR]:               org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:513)
[18:05:36 ERROR]:               com.pie.tlatoani.CustomEvent.EffCallCustomEvent.execute(EffCallCustomEvent.java:42)
[18:05:36 ERROR]:               ch.njol.skript.lang.Effect.run(Effect.java:52)
[18:05:36 ERROR]:               ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[18:05:36 ERROR]:               ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[18:05:36 ERROR]:               com.btk5h.reqn.skript.EffRequest.lambda$null$1(EffRequest.java:112)
[18:05:36 ERROR]:               com.btk5h.reqn.skript.EffRequest$$Lambda$653/1985622394.run(Unknown Source)
[18:05:36 ERROR]:               org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:63)
[18:05:36 ERROR]:               org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:423)
[18:05:36 ERROR]:               net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:840)
[18:05:36 ERROR]:               net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423)
[18:05:36 ERROR]:               net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774)
[18:05:36 ERROR]:               net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666)
[18:05:36 ERROR]:               java.lang.Thread.run(Thread.java:748)

on join:
  send request to "xxxx/api?player=%player%"
  map json last response's body to {player::%player%::*}
  call custom event "load" to details player

using this script i'm load statistics, level, coins etc. everything works great but after some time server get crash and nobody can join to server.

Feature request: default user agent.

Users tend to have issues because they normally don't use an user agent and thus, the requests failing. I'd say having a default one would probably be a good solution to this.

Reqn is blocked

Hello,
I use reqn with the api of a voting site to check that my players have voted on the site, recently reqn is blocked it works perfectly and during the day impossible to receive the answer from a site.

I think that simply at some point during the day the voting site does not send back any answer and so it waits while blocking the other requests

403 Error

My Skript is producing a 403 error when I do the following code, but if I access the URL via Chrome on the same server, it works perfectly fine.

command /auth:
	trigger:
		set {_rnd} to random integer from 1 to 4096
		set {_prehash} to hashed "RST%player%RST%now%%{_rnd}%"
		set {_hash} to the first 12 characters of "%{_prehash}%"
		set {_name} to "%name of player%"
		set {_uuid} to the uuid of player
		set {_sname} to url safe {_name}
		set {_suuid} to url safe {_uuid}
		set {_shash} to url safe {_hash}
		set {_url} to "http://auth.redstonetor.ch/upload_details.php?n=%{_sname}%&u=%{_suuid}%&p=%{_shash}%"
		send request to {_url}
		send {_url} to console
		set {_tmp} to last http response
		send "%last http response%" to console
		message "Thanks for authenticating your Minecraft account %{_name}%!%nl%%nl%Your one time key is%nl%%nl%-[ &l%{_hash}%&r ]-%nl%%nl%Please enter this code into the key box.%nl%%{_url}%%nl%%{_tmp}%"

[15:37:55 INFO]: TheMeq issued server command: /auth
[15:37:55 INFO]: TheMeq [9a797364-5055-4aaa-916e-8356de399524]: /auth
[15:37:56 INFO]: http://auth.redstonetor.ch/upload_details.php?n=NAME&u=UUID&p=KEY
[15:37:56 INFO]: HTTP/1.1 403 Forbidden
X-Frame-Options: SAMEORIGIN
Keep-Alive: timeout=5, max=100
Strict-Transport-Security: max-age=63072000; includeSubDomains
Server: Apache
X-Content-Type-Options: nosniff
Connection: Keep-Alive
Content-Length: 346
Date: Fri, 12 May 2017 14:37:51 GMT
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /upload_details.php
on this server.<br />
</p>
<p>Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request
.</p>
</body></html>

send a request doesn't wait for the request to finish before continuing

send a request to "google.com"
set {_h} to last http response

sometimes/often times {_h} isn't the request from the first line but rather the one before it. pls make it wait for the request to finish before continuing, or add the ability to do something like set {_h} to send a request to "google.com"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.