Skip to content

Commit b436a5d

Browse files
committed
add: test for custom HTTP Method
add: test for HTTPs
1 parent 6739da6 commit b436a5d

36 files changed

+416
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"io/ioutil"
7+
)
8+
9+
func main() {
10+
11+
url := "http://mockbin.com/har"
12+
13+
req, _ := http.NewRequest("PROPFIND", url, nil)
14+
15+
res, _ := http.DefaultClient.Do(req)
16+
17+
defer res.Body.Close()
18+
body, _ := ioutil.ReadAll(res.Body)
19+
20+
fmt.Println(res)
21+
fmt.Println(string(body))
22+
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"io/ioutil"
7+
)
8+
9+
func main() {
10+
11+
url := "https://mockbin.com/har"
12+
13+
req, _ := http.NewRequest("GET", url, nil)
14+
15+
res, _ := http.DefaultClient.Do(req)
16+
17+
defer res.Body.Close()
18+
body, _ := ioutil.ReadAll(res.Body)
19+
20+
fmt.Println(res)
21+
fmt.Println(string(body))
22+
23+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HttpResponse<String> response = Unirest.customMethod("PROPFIND","http://mockbin.com/har")
2+
.asString();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HttpResponse<String> response = Unirest.get("https://mockbin.com/har")
2+
.asString();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var settings = {
2+
"async": true,
3+
"crossDomain": true,
4+
"url": "http://mockbin.com/har",
5+
"method": "PROPFIND",
6+
"headers": {}
7+
}
8+
9+
$.ajax(settings).done(function (response) {
10+
console.log(response);
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var settings = {
2+
"async": true,
3+
"crossDomain": true,
4+
"url": "https://mockbin.com/har",
5+
"method": "GET",
6+
"headers": {}
7+
}
8+
9+
$.ajax(settings).done(function (response) {
10+
console.log(response);
11+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var data = null;
2+
3+
var xhr = new XMLHttpRequest();
4+
xhr.withCredentials = true;
5+
6+
xhr.addEventListener("readystatechange", function () {
7+
if (this.readyState === this.DONE) {
8+
console.log(this.responseText);
9+
}
10+
});
11+
12+
xhr.open("PROPFIND", "http://mockbin.com/har");
13+
14+
xhr.send(data);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var data = null;
2+
3+
var xhr = new XMLHttpRequest();
4+
xhr.withCredentials = true;
5+
6+
xhr.addEventListener("readystatechange", function () {
7+
if (this.readyState === this.DONE) {
8+
console.log(this.responseText);
9+
}
10+
});
11+
12+
xhr.open("GET", "https://mockbin.com/har");
13+
14+
xhr.send(data);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var http = require("http");
2+
3+
var options = {
4+
"method": "PROPFIND",
5+
"hostname": "mockbin.com",
6+
"port": null,
7+
"path": "/har",
8+
"headers": {}
9+
};
10+
11+
var req = http.request(options, function (res) {
12+
var chunks = [];
13+
14+
res.on("data", function (chunk) {
15+
chunks.push(chunk);
16+
});
17+
18+
res.on("end", function () {
19+
var body = Buffer.concat(chunks);
20+
console.log(body);
21+
});
22+
});
23+
24+
req.end();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var http = require("http");
2+
3+
var options = {
4+
"method": "GET",
5+
"hostname": "mockbin.com",
6+
"port": null,
7+
"path": "/har",
8+
"headers": {}
9+
};
10+
11+
var req = http.request(options, function (res) {
12+
var chunks = [];
13+
14+
res.on("data", function (chunk) {
15+
chunks.push(chunk);
16+
});
17+
18+
res.on("end", function () {
19+
var body = Buffer.concat(chunks);
20+
console.log(body);
21+
});
22+
});
23+
24+
req.end();

0 commit comments

Comments
 (0)