| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #include "mhttp.h" |
| 5 |
|
| |
| 6 |
|
| |
| 7 |
3 |
| void my_http_reset( ) { |
| 8 |
|
| |
| 9 |
3 |
| mhttp_reset(); |
| 10 |
|
| |
| 11 |
3 |
| } |
| 12 |
|
| |
| 13 |
2 |
| void my_http_init( ) { |
| 14 |
|
| |
| 15 |
2 |
| mhttp_init(); |
| 16 |
|
| |
| 17 |
2 |
| } |
| 18 |
|
| |
| 19 |
1 |
| void my_http_set_protocol(SV* sv_proto) { |
| 20 |
|
| |
| 21 |
1 |
| mhttp_set_protocol(SvIV(sv_proto)); |
| 22 |
|
| |
| 23 |
1 |
| } |
| 24 |
|
| |
| 25 |
0 |
| void my_switch_debug(SV* sv_swt) { |
| 26 |
|
| |
| 27 |
0 |
| mhttp_switch_debug(SvIV(sv_swt)); |
| 28 |
|
| |
| 29 |
0 |
| } |
| 30 |
|
| |
| 31 |
8 |
| void my_add_header(SV* sv_hdr) { |
| 32 |
|
| |
| 33 |
16 |
| mhttp_add_header(SvPV(sv_hdr,SvCUR(sv_hdr))); |
| 34 |
|
| |
| 35 |
8 |
| } |
| 36 |
|
| |
| 37 |
1 |
| SV* my_http_headers( ) { |
| 38 |
|
| |
| 39 |
1 |
| return newSVpv(mhttp_get_response_headers(),0); |
| 40 |
|
| |
| 41 |
|
| } |
| 42 |
|
| |
| 43 |
0 |
| void my_http_body(SV* sv_bdy) { |
| 44 |
|
| |
| 45 |
0 |
| mhttp_set_body( |
| 46 |
0 |
| SvPV(sv_bdy,SvCUR(sv_bdy)) |
| 47 |
|
| ); |
| 48 |
|
| |
| 49 |
0 |
| } |
| 50 |
|
| |
| 51 |
1 |
| SV* my_http_reason( ) { |
| 52 |
|
| |
| 53 |
|
| char* reason; |
| 54 |
|
| |
| 55 |
1 |
| reason = mhttp_get_reason(); |
| 56 |
|
| |
| 57 |
1 |
▶ | if (reason != NULL){ |
Branch: 1 branch
| Branch | True | False | Total |
| if (reason != NULL){ |
1 |
0 |
1 |
|
| 58 |
1 |
| return newSVpv(reason,0); |
| 59 |
|
| } else { |
| 60 |
0 |
| return newSVsv(&PL_sv_undef); |
| 61 |
|
| } |
| 62 |
|
| |
| 63 |
|
| } |
| 64 |
|
| |
| 65 |
1 |
| SV* my_http_response( ) { |
| 66 |
|
| |
| 67 |
1 |
▶ | if (mhttp_get_response_length() > 0){ |
Branch: 1 branch
| Branch | True | False | Total |
| if (mhttp_get_response_length() > 0){ |
1 |
0 |
1 |
|
| 68 |
1 |
| return newSVpv(mhttp_get_response(),mhttp_get_response_length()); |
| 69 |
|
| } else { |
| 70 |
0 |
| return newSVsv(&PL_sv_undef); |
| 71 |
|
| } |
| 72 |
|
| |
| 73 |
|
| } |
| 74 |
|
| |
| 75 |
1 |
| SV* my_http_status( ) { |
| 76 |
|
| |
| 77 |
1 |
| return newSViv(mhttp_get_status_code()); |
| 78 |
|
| |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
0 |
| SV* my_http_response_length( ) { |
| 82 |
|
| |
| 83 |
0 |
| return newSViv(mhttp_get_response_length()); |
| 84 |
|
| |
| 85 |
|
| } |
| 86 |
|
| |
| 87 |
4 |
| SV* my_http_call(SV* sv_action, SV* sv_url) { |
| 88 |
|
| |
| 89 |
12 |
▶ | return newSViv( |
Branch: 1 branch
| Branch | True | False | Total |
| return newSViv( |
4 |
0 |
4 |
|
| 90 |
|
| mhttp_call( |
| 91 |
|
| SvPV(sv_action,SvCUR(sv_action)), |
| 92 |
|
| SvPV(sv_url,SvCUR(sv_url)) |
| 93 |
|
| ) |
| 94 |
|
| ); |
| 95 |
|
| |
| 96 |
|
| } |
| 97 |
|
| |
| 98 |
|
| |
| 99 |
|
| MODULE = HTTP::MHTTP PACKAGE = HTTP::MHTTP PREFIX = my_ |
| 100 |
|
| |
| 101 |
|
| PROTOTYPES: DISABLE |
| 102 |
|
| |
| 103 |
|
| void |
| 104 |
|
| my_http_reset ( ) |
| 105 |
|
| |
| 106 |
|
| void |
| 107 |
|
| my_http_init ( ) |
| 108 |
|
| |
| 109 |
|
| void |
| 110 |
|
| my_http_set_protocol (sv_proto) |
| 111 |
|
| SV * sv_proto |
| 112 |
|
| |
| 113 |
|
| void |
| 114 |
|
| my_switch_debug (sv_swt) |
| 115 |
|
| SV * sv_swt |
| 116 |
|
| |
| 117 |
|
| void |
| 118 |
|
| my_add_header (sv_hdr) |
| 119 |
|
| SV * sv_hdr |
| 120 |
|
| |
| 121 |
|
| SV* |
| 122 |
|
| my_http_headers ( ) |
| 123 |
|
| |
| 124 |
|
| void |
| 125 |
|
| my_http_body (sv_bdy) |
| 126 |
|
| SV * sv_bdy |
| 127 |
|
| |
| 128 |
|
| SV* |
| 129 |
|
| my_http_reason ( ) |
| 130 |
|
| |
| 131 |
|
| SV* |
| 132 |
|
| my_http_response ( ) |
| 133 |
|
| |
| 134 |
|
| SV* |
| 135 |
|
| my_http_status ( ) |
| 136 |
|
| |
| 137 |
|
| SV* |
| 138 |
|
| my_http_response_length ( ) |
| 139 |
|
| |
| 140 |
|
| SV* |
| 141 |
|
| my_http_call (sv_action, sv_url) |
| 142 |
|
| SV * sv_action |
| 143 |
|
| SV * sv_url |
| 144 |
|
| |