Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const {cx_root} = await import("./cx_root.clas.mjs"); // cl_http_client.clas.abap class cl_http_client { static INTERNAL_TYPE = 'CLAS'; static INTERNAL_NAME = 'CL_HTTP_CLIENT'; static IMPLEMENTED_INTERFACES = ["IF_HTTP_CLIENT"]; static ATTRIBUTES = {"MV_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~REQUEST": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_REQUEST", RTTIName: "\\INTERFACE=IF_HTTP_REQUEST"});}, "visibility": "U", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~RESPONSE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_RESPONSE", RTTIName: "\\INTERFACE=IF_HTTP_RESPONSE"});}, "visibility": "U", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~PROPERTYTYPE_LOGON_POPUP": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~PROPERTYTYPE_ACCEPT_COOKIE": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~PROPERTYTYPE_REDIRECT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": " ", "is_class": " "}, "IF_HTTP_CLIENT~CO_DISABLED": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": "X", "is_class": "X"}, "IF_HTTP_CLIENT~CO_ENABLED": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": "X", "is_class": "X"}, "IF_HTTP_CLIENT~CO_TIMEOUT_DEFAULT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": "X", "is_class": "X"}}; static METHODS = {"CREATE_BY_URL": {"visibility": "U", "parameters": {"URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "SSL_ID": {"type": () => {return new abap.types.Character(6, {"qualifiedName":"SSFAPPLSSL","ddicName":"SSFAPPLSSL","description":"SSL ID"});}, "is_optional": " "}, "PROXY_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "PROXY_SERVICE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}}}, "CREATE_BY_DESTINATION": {"visibility": "U", "parameters": {"DESTINATION": {"type": () => {return new abap.types.Character();}, "is_optional": " "}, "CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}}}, "CREATE_INTERNAL": {"visibility": "U", "parameters": {"CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}}}, "CONSTRUCTOR": {"visibility": "U", "parameters": {"URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}}; #mv_host; constructor() { this.me = new abap.types.ABAPObject(); this.me.set(this); this.INTERNAL_ID = abap.internalIdCounter++; this.FRIENDS_ACCESS_INSTANCE = { }; this.#mv_host = new abap.types.String({qualifiedName: "STRING"}); this.FRIENDS_ACCESS_INSTANCE["mv_host"] = this.#mv_host; this.if_http_client$co_disabled = abap.Classes['IF_HTTP_CLIENT'].if_http_client$co_disabled; this.if_http_client$co_enabled = abap.Classes['IF_HTTP_CLIENT'].if_http_client$co_enabled; this.if_http_client$co_timeout_default = abap.Classes['IF_HTTP_CLIENT'].if_http_client$co_timeout_default; if (this.if_http_client$request === undefined) this.if_http_client$request = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_REQUEST", RTTIName: "\\INTERFACE=IF_HTTP_REQUEST"}); if (this.if_http_client$response === undefined) this.if_http_client$response = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_RESPONSE", RTTIName: "\\INTERFACE=IF_HTTP_RESPONSE"}); if (this.if_http_client$propertytype_logon_popup === undefined) this.if_http_client$propertytype_logon_popup = new abap.types.Integer({qualifiedName: "I"}); if (this.if_http_client$propertytype_accept_cookie === undefined) this.if_http_client$propertytype_accept_cookie = new abap.types.Integer({qualifiedName: "I"}); if (this.if_http_client$propertytype_redirect === undefined) this.if_http_client$propertytype_redirect = new abap.types.Integer({qualifiedName: "I"}); } async constructor_(INPUT) { let url = INPUT?.url; if (url?.getQualifiedName === undefined || url.getQualifiedName() !== "STRING") { url = undefined; } if (url === undefined) { url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.url); } let lv_uri = new abap.types.String({qualifiedName: "STRING"}); let lv_query = new abap.types.String({qualifiedName: "STRING"}); this.if_http_client$response.set(await (new abap.Classes['CL_HTTP_ENTITY']()).constructor_()); abap.statements.find(url, {regex: abap.CharacterFactory.get(19, '\\w(\\/[\\w\\d\\.\\-\\/]+)'), submatches: [lv_uri]}); this.#mv_host.set(url); abap.statements.replace({target: this.#mv_host, all: false, with: abap.CharacterFactory.get(1, ''), of: lv_uri}); this.if_http_client$request.set(await (new abap.Classes['CL_HTTP_ENTITY']()).constructor_()); await this.if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(12, '~request_uri'), value: lv_uri}); abap.statements.find(url, {regex: abap.CharacterFactory.get(6, '\\?(.*)'), submatches: [lv_query]}); if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) { await abap.Classes['CL_HTTP_UTILITY'].set_query({request: this.if_http_client$request, query: lv_query}); } return this; } async if_http_client$escape_url(INPUT) { return cl_http_client.if_http_client$escape_url(INPUT); } static async if_http_client$escape_url(INPUT) { let escaped = new abap.types.String({qualifiedName: "STRING"}); let unescaped = INPUT?.unescaped; if (unescaped?.getQualifiedName === undefined || unescaped.getQualifiedName() !== "STRING") { unescaped = undefined; } if (unescaped === undefined) { unescaped = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.unescaped); } abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo'))); return escaped; } async create_by_url(INPUT) { return cl_http_client.create_by_url(INPUT); } static async create_by_url(INPUT) { let url = INPUT?.url; if (url?.getQualifiedName === undefined || url.getQualifiedName() !== "STRING") { url = undefined; } if (url === undefined) { url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.url); } let ssl_id = new abap.types.Character(6, {"qualifiedName":"SSFAPPLSSL","ddicName":"SSFAPPLSSL","description":"SSL ID"}); if (INPUT && INPUT.ssl_id) {ssl_id.set(INPUT.ssl_id);} let proxy_host = new abap.types.String({qualifiedName: "STRING"}); if (INPUT && INPUT.proxy_host) {proxy_host.set(INPUT.proxy_host);} let proxy_service = new abap.types.String({qualifiedName: "STRING"}); if (INPUT && INPUT.proxy_service) {proxy_service.set(INPUT.proxy_service);} let client = INPUT?.client || new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"}); client.set(await (new abap.Classes['CL_HTTP_CLIENT']()).constructor_({url: url})); abap.builtin.sy.get().subrc.set(abap.IntegerFactory.get(0)); } async if_http_client$authenticate(INPUT) { let proxy_authentication = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}); if (INPUT && INPUT.proxy_authentication) {proxy_authentication.set(INPUT.proxy_authentication);} let username = INPUT?.username; if (username?.getQualifiedName === undefined || username.getQualifiedName() !== "STRING") { username = undefined; } if (username === undefined) { username = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.username); } let password = INPUT?.password; if (password?.getQualifiedName === undefined || password.getQualifiedName() !== "STRING") { password = undefined; } if (password === undefined) { password = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.password); } let lv_base64 = new abap.types.String({qualifiedName: "STRING"}); lv_base64.set((await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$encode_base64({unencoded: new abap.types.String().set(`${abap.templateFormatting(username)}:${abap.templateFormatting(password)}`)}))); await this.if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(13, 'authorization'), value: new abap.types.String().set(`Basic ${abap.templateFormatting(lv_base64)}`)}); } async if_http_client$close() { return; } async create_by_destination(INPUT) { return cl_http_client.create_by_destination(INPUT); } static async create_by_destination(INPUT) { let destination = INPUT?.destination; let client = INPUT?.client || new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"}); abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo'))); } async create_internal(INPUT) { return cl_http_client.create_internal(INPUT); } static async create_internal(INPUT) { let client = INPUT?.client || new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"}); abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo'))); abap.builtin.sy.get().subrc.set(0); } async if_http_client$create_abs_url(INPUT) { let url = new abap.types.String({qualifiedName: "STRING"}); let path = new abap.types.String({qualifiedName: "STRING"}); if (INPUT && INPUT.path) {path.set(INPUT.path);} abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo'))); return url; } async if_http_client$send(INPUT) { let timeout = new abap.types.Integer({qualifiedName: "I"}); if (INPUT && INPUT.timeout) {timeout.set(INPUT.timeout);} if (INPUT === undefined || INPUT.timeout === undefined) {timeout = abap.IntegerFactory.get(0);} let lv_method = new abap.types.String({qualifiedName: "STRING"}); let lv_url = new abap.types.String({qualifiedName: "STRING"}); let lv_body = new abap.types.String({qualifiedName: "STRING"}); let lv_name = new abap.types.String({qualifiedName: "STRING"}); let lv_value = new abap.types.String({qualifiedName: "STRING"}); let lv_content_type = new abap.types.String({qualifiedName: "STRING"}); let lv_xstr = new abap.types.XString({qualifiedName: "XSTRING"}); let lt_form_fields = abap.types.TableFactory.construct(new abap.types.Structure({ "name": new abap.types.String({qualifiedName: "STRING"}), "value": new abap.types.String({qualifiedName: "STRING"})}, "IHTTPNVP", "IHTTPNVP", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "TIHTTPNVP"); let lt_header_fields = abap.types.TableFactory.construct(new abap.types.Structure({ "name": new abap.types.String({qualifiedName: "STRING"}), "value": new abap.types.String({qualifiedName: "STRING"})}, "IHTTPNVP", "IHTTPNVP", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "TIHTTPNVP"); let ls_field = new abap.types.Structure({ "name": new abap.types.String({qualifiedName: "STRING"}), "value": new abap.types.String({qualifiedName: "STRING"})}, "IHTTPNVP", "IHTTPNVP", {}, {}); let lo_entity = new abap.types.ABAPObject({qualifiedName: "CL_HTTP_ENTITY", RTTIName: "\\CLASS=CL_HTTP_ENTITY"}); lv_method.set((await this.if_http_client$request.get().if_http_request$get_method())); if (abap.compare.initial(lv_method)) { lv_method.set(abap.CharacterFactory.get(3, 'GET')); } if (abap.compare.initial((await this.if_http_client$request.get().if_http_entity$get_header_field({name: abap.CharacterFactory.get(10, 'user-agent')})))) { await this.if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(10, 'user-agent'), value: abap.CharacterFactory.get(14, 'open-abap-http')}); } lv_url.set((await this.if_http_client$request.get().if_http_entity$get_header_field({name: abap.CharacterFactory.get(12, '~request_uri')}))); abap.statements.replace({target: lv_url, all: false, with: abap.CharacterFactory.get(1, ''), of: this.#mv_host}); lv_url.set(abap.operators.concat(this.#mv_host,lv_url)); await this.if_http_client$request.get().if_http_entity$get_form_fields({fields: lt_form_fields}); if (abap.compare.gt(abap.builtin.lines({val: lt_form_fields}), abap.IntegerFactory.get(0))) { let unique1139 = lv_method; if (abap.compare.eq(unique1139, abap.CharacterFactory.get(3, 'GET'))) { lv_url.set(abap.operators.concat(lv_url,abap.operators.concat(abap.CharacterFactory.get(1, '?'),(await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$fields_to_string({fields: lt_form_fields}))))); } else if (abap.compare.eq(unique1139, abap.CharacterFactory.get(4, 'POST'))) { await this.if_http_client$request.get().if_http_entity$set_cdata({data: (await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$fields_to_string({fields: lt_form_fields}))}); } } await this.if_http_client$request.get().if_http_entity$get_header_fields({fields: lt_header_fields}); let headers = {}; for await (const unique1140 of abap.statements.loop(lt_header_fields,{where: async (I) => {return abap.compare.ne(I.name, abap.CharacterFactory.get(12, '~request_uri'));}})) { ls_field.set(unique1140); headers[ls_field.get().name.get()] = ls_field.get().value.get(); } lv_content_type.set((await this.if_http_client$request.get().if_http_entity$get_content_type())); if (abap.compare.initial(lv_content_type) === false) { headers["content-type"] = lv_content_type.get(); } headers["accept-encoding"] = "gzip"; lv_body.set((await this.if_http_client$request.get().if_http_entity$get_cdata())); if (abap.compare.gt(abap.builtin.strlen({val: lv_body}), abap.IntegerFactory.get(0))) { headers["content-length"] = lv_body.get().length; } const https = await import("https"); const http = await import("http"); function postData(url, options, requestBody) { return new Promise((resolve, reject) => { const prot = url.startsWith("http://") ? http : https; const req = prot.request(url, options, (res) => { let chunks = []; res.on("data", (chunk) => {chunks.push(chunk);}); res.on("error", reject); res.on("end", () => { resolve({statusCode: res.statusCode, headers: res.headers, body: Buffer.concat(chunks)}); }); }); req.on("error", reject); req.write(requestBody, "binary"); req.end(); }); } const prot = lv_url.get().startsWith("http://") ? http : https; if (this.agent === undefined) {this.agent = new prot.Agent({keepAlive: true, maxSockets: 1});} let response = await postData(lv_url.get(), {method: lv_method.get(), headers: headers, agent: this.agent}, lv_body.get()); for (const h in response.headers) { lv_name.set(h); if (Array.isArray(response.headers[h])) continue; lv_value.set(response.headers[h]); await this.if_http_client$response.get().if_http_entity$set_header_field({name: lv_name, value: lv_value}); } await abap.statements.cast(lo_entity, this.if_http_client$response); lo_entity.get().mv_content_type.set(response.headers["content-type"] || ""); lo_entity.get().mv_status.set(response.statusCode); lo_entity.get().mv_data.set(response.body.toString("hex").toUpperCase()); lv_value.set((await this.if_http_client$response.get().if_http_entity$get_header_field({name: abap.CharacterFactory.get(16, 'content-encoding')}))); if (abap.compare.eq(lv_value, abap.CharacterFactory.get(4, 'gzip'))) { await abap.Classes['CL_ABAP_GZIP'].decompress_binary_with_header({gzip_in: (await this.if_http_client$response.get().if_http_entity$get_data()), raw_out: lv_xstr}); await this.if_http_client$response.get().if_http_entity$set_data({data: lv_xstr}); } abap.builtin.sy.get().subrc.set(abap.IntegerFactory.get(0)); } async if_http_client$receive() { abap.builtin.sy.get().subrc.set(abap.IntegerFactory.get(0)); } async if_http_client$get_last_error(INPUT) { let code = INPUT?.code || new abap.types.Integer({qualifiedName: "SYSUBRC"}); let message = INPUT?.message || new abap.types.String({qualifiedName: "STRING"}); let message_class = INPUT?.message_class || new abap.types.Character(20, {}); let message_number = INPUT?.message_number || new abap.types.Character(3, {}); await this.if_http_client$response.get().if_http_response$get_status({code: code}); message.set(abap.CharacterFactory.get(14, 'todo_open_abap')); } async if_http_client$send_sap_logon_ticket() { return; } async if_http_client$refresh_request() { abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo'))); } } abap.Classes['CL_HTTP_CLIENT'] = cl_http_client; cl_http_client.if_http_client$co_disabled = new abap.types.Integer({qualifiedName: "I"}); cl_http_client.if_http_client$co_disabled.set(0); cl_http_client.if_http_client$co_enabled = new abap.types.Integer({qualifiedName: "I"}); cl_http_client.if_http_client$co_enabled.set(1); cl_http_client.if_http_client$co_timeout_default = new abap.types.Integer({qualifiedName: "I"}); cl_http_client.if_http_client$co_timeout_default.set(60); export {cl_http_client}; |