-
Notifications
You must be signed in to change notification settings - Fork 60
/
http.cna
65 lines (43 loc) · 1.23 KB
/
http.cna
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
alias send {
$method = "GET";
$url = "https://www.google.com";
$body = "";
$response = sendhttp($method, $url, $body);
elog($response);
}
# sendhttp
# GET/POST
# URL
# POST BODY
sub sendhttp{
$method = $1;
$url = $2;
$body = $3 . "\r\n";
$USER_AGENT = "Mozilla/5.0";
$urlobj = [new URL: $url];
$con = [$urlobj openConnection];
[$con setRequestMethod: $method];
[$con setRequestProperty: "User-Agent", $USER_AGENT];
[$con setDoOutput: true];
$wr = [new DataOutputStream: [$con getOutputStream]];
[$wr writeBytes: $body];
[$wr flush];
[$wr close];
$responseCode = [$con getResponseCode];
$in = [new BufferedReader: [new InputStreamReader: [$con getInputStream]]];
$inputLine = "";
$response = "";
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
while ($inputLine ne ""){
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
}
[$in close];
return $response;
}