mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-03-31 09:13:38 -04:00
Added GET request support for media end point
This commit is contained in:
parent
cddb143cf7
commit
c43ffd6dd3
@ -7,7 +7,7 @@ import java.awt.Font
|
|||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
|
|
||||||
class FilterChallenge extends ChallengeProvider {
|
class FilterChallenge extends ChallengeProvider {
|
||||||
def getId = "filter"
|
def getId = "FilterChallenge"
|
||||||
def returnChallenge(): Challenge = {
|
def returnChallenge(): Challenge = {
|
||||||
val filterTypes = List(new FilterType1, new FilterType2)
|
val filterTypes = List(new FilterType1, new FilterType2)
|
||||||
val r = new scala.util.Random
|
val r = new scala.util.Random
|
||||||
|
@ -126,14 +126,20 @@ class Server(port: Int){
|
|||||||
},"POST")
|
},"POST")
|
||||||
|
|
||||||
host.addContext("/v1/media",(req, resp) => {
|
host.addContext("/v1/media",(req, resp) => {
|
||||||
val body = req.getJson()
|
var id = Id(null)
|
||||||
val json = parse(body)
|
if ("GET" == req.getMethod()){
|
||||||
val id = json.extract[Id]
|
val params = req.getParams()
|
||||||
|
id = Id(params.get("id"))
|
||||||
|
} else {
|
||||||
|
val body = req.getJson()
|
||||||
|
val json = parse(body)
|
||||||
|
id = json.extract[Id]
|
||||||
|
}
|
||||||
val image = captcha.getCaptcha(id)
|
val image = captcha.getCaptcha(id)
|
||||||
resp.getHeaders().add("Content-Type","image/png")
|
resp.getHeaders().add("Content-Type","image/png")
|
||||||
resp.send(200, image)
|
resp.send(200, image)
|
||||||
0
|
0
|
||||||
},"POST")
|
},"POST", "GET")
|
||||||
|
|
||||||
host.addContext("/v1/answer",(req, resp) => {
|
host.addContext("/v1/answer",(req, resp) => {
|
||||||
val body = req.getJson()
|
val body = req.getJson()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user