All files / output zcl_abapgit_http.clas.mjs

16.84% Statements 47/279
100% Branches 2/2
2.43% Functions 1/41
16.84% Lines 47/279

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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 2791x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x               1x       1x     1x                                                                       1x     1x                       1x     1x           1x     1x                                                                                                       1x     1x         1x     1x                                                     1x     1x                                                                                                           1x     1x                                         1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_http.clas.abap
class zcl_abapgit_http {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_HTTP';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"C_SCHEME": {"type": () => {return new abap.types.Structure({
  "digest": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});}, "visibility": "U", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"CHECK_AUTH_REQUESTED": {"visibility": "O", "parameters": {"RV_AUTH_REQUESTED": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "II_CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}}},
  "IS_LOCAL_SYSTEM": {"visibility": "O", "parameters": {"RV_BOOL": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "ACQUIRE_LOGIN_DETAILS": {"visibility": "O", "parameters": {"RV_SCHEME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "II_CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}, "IO_CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTTP_CLIENT", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTTP_CLIENT"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "GET_HTTP_CLIENT": {"visibility": "O", "parameters": {"RI_CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "GET_CONNECTION_LONGTEXT": {"visibility": "O", "parameters": {"RV_LONGTEXT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_SSL_ID": {"type": () => {return new abap.types.Character(6, {"qualifiedName":"SSFAPPLSSL","ddicName":"SSFAPPLSSL","description":"SSL ID"});}, "is_optional": " "}, "IV_PROXY_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_PROXY_SERVICE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "GET_AGENT": {"visibility": "U", "parameters": {"RV_AGENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "CREATE_BY_URL": {"visibility": "U", "parameters": {"RO_CLIENT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTTP_CLIENT", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTTP_CLIENT"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_SERVICE": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IT_HEADERS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "key": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-KEY"}),
  "value": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-VALUE"})}, "zcl_abapgit_http=>ty_key_value", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zcl_abapgit_http=>ty_headers");}, "is_optional": " "}}},
  "CHECK_CONNECTION": {"visibility": "U", "parameters": {"IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.c_scheme = zcl_abapgit_http.c_scheme;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async acquire_login_details(INPUT) {
    return zcl_abapgit_http.acquire_login_details(INPUT);
  }
  static async acquire_login_details(INPUT) {
    let rv_scheme = new abap.types.String({qualifiedName: "STRING"});
    let ii_client = INPUT?.ii_client;
    if (ii_client?.getQualifiedName === undefined || ii_client.getQualifiedName() !== "IF_HTTP_CLIENT") { ii_client = undefined; }
    if (ii_client === undefined) { ii_client = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"}).set(INPUT.ii_client); }
    let io_client = INPUT?.io_client;
    if (io_client?.getQualifiedName === undefined || io_client.getQualifiedName() !== "ZCL_ABAPGIT_HTTP_CLIENT") { io_client = undefined; }
    if (io_client === undefined) { io_client = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTTP_CLIENT", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTTP_CLIENT"}).set(INPUT.io_client); }
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lv_default_user = new abap.types.String({qualifiedName: "STRING"});
    let lv_user = new abap.types.String({qualifiedName: "STRING"});
    let lv_pass = new abap.types.String({qualifiedName: "STRING"});
    let lo_digest = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTTP_DIGEST", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTTP_DIGEST"});
    lv_default_user.set((await (await abap.Classes['ZCL_ABAPGIT_PERSIST_FACTORY'].get_user()).get().zif_abapgit_persist_user$get_repo_login({iv_url: iv_url})));
    lv_user.set(lv_default_user);
    await abap.Classes['ZCL_ABAPGIT_PASSWORD_DIALOG'].popup({iv_repo_url: iv_url, cv_user: lv_user, cv_pass: lv_pass});
    if (abap.compare.initial(lv_user)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(43, 'Unauthorized access. Check your credentials')});
    }
    if (abap.compare.ne(lv_user, lv_default_user)) {
      await (await abap.Classes['ZCL_ABAPGIT_PERSIST_FACTORY'].get_user()).get().zif_abapgit_persist_user$set_repo_login({iv_url: iv_url, iv_login: lv_user});
    }
    rv_scheme.set((await ii_client.get().if_http_client$response.get().if_http_entity$get_header_field({name: abap.CharacterFactory.get(16, 'www-authenticate')})));
    abap.statements.find(rv_scheme, {regex: abap.CharacterFactory.get(6, '^(\\w+)'), submatches: [rv_scheme]});
    let unique235 = rv_scheme;
    if (abap.compare.eq(unique235, zcl_abapgit_http.c_scheme.get().digest)) {
      lo_digest.set(await (new abap.Classes['ZCL_ABAPGIT_HTTP_DIGEST']()).constructor_({ii_client: ii_client, iv_username: lv_user, iv_password: lv_pass}));
      await lo_digest.get().run({ii_client: ii_client});
      await io_client.get().set_digest({io_digest: lo_digest});
    } else {
      await ii_client.get().if_http_client$authenticate({username: lv_user, password: lv_pass});
    }
    return rv_scheme;
  }
  async check_auth_requested(INPUT) {
    return zcl_abapgit_http.check_auth_requested(INPUT);
  }
  static async check_auth_requested(INPUT) {
    let rv_auth_requested = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let ii_client = INPUT?.ii_client;
    if (ii_client?.getQualifiedName === undefined || ii_client.getQualifiedName() !== "IF_HTTP_CLIENT") { ii_client = undefined; }
    if (ii_client === undefined) { ii_client = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"}).set(INPUT.ii_client); }
    let lv_code = new abap.types.Integer({qualifiedName: "I"});
    await ii_client.get().if_http_client$response.get().if_http_response$get_status({code: lv_code});
    if (abap.compare.eq(lv_code, new abap.types.Integer().set(401))) {
      rv_auth_requested.set(abap.builtin.abap_true);
    }
    return rv_auth_requested;
  }
  async check_connection(INPUT) {
    return zcl_abapgit_http.check_connection(INPUT);
  }
  static async check_connection(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    await this.get_http_client({iv_url: iv_url});
  }
  async create_by_url(INPUT) {
    return zcl_abapgit_http.create_by_url(INPUT);
  }
  static async create_by_url(INPUT) {
    let ro_client = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_HTTP_CLIENT", RTTIName: "\\CLASS=ZCL_ABAPGIT_HTTP_CLIENT"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let iv_service = INPUT?.iv_service;
    if (iv_service?.getQualifiedName === undefined || iv_service.getQualifiedName() !== "STRING") { iv_service = undefined; }
    if (iv_service === undefined) { iv_service = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_service); }
    let it_headers = abap.types.TableFactory.construct(new abap.types.Structure({
    "key": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-KEY"}),
    "value": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-VALUE"})}, "zcl_abapgit_http=>ty_key_value", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zcl_abapgit_http=>ty_headers");
    if (INPUT && INPUT.it_headers) {it_headers.set(INPUT.it_headers);}
    let lv_uri = new abap.types.String({qualifiedName: "STRING"});
    let lv_scheme = new abap.types.String({qualifiedName: "STRING"});
    let lv_authorization = new abap.types.String({qualifiedName: "STRING"});
    let li_client = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});
    let ls_header = new abap.types.Structure({
    "key": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-KEY"}),
    "value": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-VALUE"})}, "zcl_abapgit_http=>ty_key_value", undefined, {}, {});
    li_client.set((await this.get_http_client({iv_url: iv_url})));
    ro_client.set(await (new abap.Classes['ZCL_ABAPGIT_HTTP_CLIENT']()).constructor_({ii_client: li_client}));
    if (abap.compare.eq((await this.is_local_system({iv_url: iv_url})), abap.builtin.abap_true)) {
      await li_client.get().if_http_client$send_sap_logon_ticket();
    }
    await li_client.get().if_http_client$request.get().if_http_entity$set_cdata({data: abap.CharacterFactory.get(1, '')});
    await li_client.get().if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(15, '~request_method'), value: abap.CharacterFactory.get(3, 'GET')});
    await li_client.get().if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(10, 'user-agent'), value: (await this.get_agent())});
    lv_uri.set(abap.operators.concat((await abap.Classes['ZCL_ABAPGIT_URL'].path_name({iv_url: iv_url})),abap.operators.concat(abap.CharacterFactory.get(23, '/info/refs?service=git-'),abap.operators.concat(iv_service,abap.CharacterFactory.get(5, '-pack')))));
    await li_client.get().if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(12, '~request_uri'), value: lv_uri});
    for await (const unique236 of abap.statements.loop(it_headers)) {
      ls_header.set(unique236);
      await li_client.get().if_http_client$request.get().if_http_entity$set_header_field({name: ls_header.get().key, value: ls_header.get().value});
    }
    li_client.get().if_http_client$propertytype_logon_popup.set(abap.Classes['IF_HTTP_CLIENT'].if_http_client$co_disabled);
    lv_authorization.set((await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].load({iv_uri: iv_url})));
    if (abap.compare.initial(lv_authorization) === false) {
      await li_client.get().if_http_client$request.get().if_http_entity$set_header_field({name: abap.CharacterFactory.get(13, 'authorization'), value: lv_authorization});
      li_client.get().if_http_client$propertytype_logon_popup.set(li_client.get().if_http_client$co_disabled);
    }
    await li_client.get().if_http_client$request.get().if_http_request$set_version({version: abap.Classes['IF_HTTP_REQUEST'].if_http_entity$co_protocol_version_1_1});
    await (await abap.Classes['ZCL_ABAPGIT_EXIT'].get_instance()).get().zif_abapgit_exit$http_client({iv_url: iv_url, ii_client: li_client});
    await ro_client.get().send_receive();
    if (abap.compare.eq((await this.check_auth_requested({ii_client: li_client})), abap.builtin.abap_true)) {
      lv_scheme.set((await this.acquire_login_details({ii_client: li_client, io_client: ro_client, iv_url: iv_url})));
      await ro_client.get().send_receive();
    }
    await ro_client.get().check_http_200();
    if (abap.compare.ne(lv_scheme, zcl_abapgit_http.c_scheme.get().digest)) {
      await abap.Classes['ZCL_ABAPGIT_LOGIN_MANAGER'].save({iv_uri: iv_url, iv_authorization: (await li_client.get().if_http_client$request.get().if_http_entity$get_header_field({name: abap.CharacterFactory.get(13, 'authorization')}))});
    }
    return ro_client;
  }
  async get_agent() {
    return zcl_abapgit_http.get_agent();
  }
  static async get_agent() {
    let rv_agent = new abap.types.String({qualifiedName: "STRING"});
    rv_agent.set(new abap.types.String().set(`git/2.0 (abapGit ${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_VERSION'].zif_abapgit_version$c_abap_version)})`));
    return rv_agent;
  }
  async get_connection_longtext(INPUT) {
    return zcl_abapgit_http.get_connection_longtext(INPUT);
  }
  static async get_connection_longtext(INPUT) {
    let rv_longtext = new abap.types.String({qualifiedName: "STRING"});
    let iv_host = INPUT?.iv_host;
    if (iv_host?.getQualifiedName === undefined || iv_host.getQualifiedName() !== "STRING") { iv_host = undefined; }
    if (iv_host === undefined) { iv_host = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_host); }
    let iv_ssl_id = INPUT?.iv_ssl_id;
    if (iv_ssl_id?.getQualifiedName === undefined || iv_ssl_id.getQualifiedName() !== "SSFAPPLSSL") { iv_ssl_id = undefined; }
    if (iv_ssl_id === undefined) { iv_ssl_id = new abap.types.Character(6, {"qualifiedName":"SSFAPPLSSL","ddicName":"SSFAPPLSSL","description":"SSL ID"}).set(INPUT.iv_ssl_id); }
    let iv_proxy_host = INPUT?.iv_proxy_host;
    if (iv_proxy_host?.getQualifiedName === undefined || iv_proxy_host.getQualifiedName() !== "STRING") { iv_proxy_host = undefined; }
    if (iv_proxy_host === undefined) { iv_proxy_host = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_proxy_host); }
    let iv_proxy_service = INPUT?.iv_proxy_service;
    if (iv_proxy_service?.getQualifiedName === undefined || iv_proxy_service.getQualifiedName() !== "STRING") { iv_proxy_service = undefined; }
    if (iv_proxy_service === undefined) { iv_proxy_service = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_proxy_service); }
    let lc_docs = new abap.types.String({qualifiedName: "STRING"});
    lc_docs.set('https://docs.abapgit.org/user-guide/setup/ssl-setup.html');
    let lv_proxy = new abap.types.String({qualifiedName: "STRING"});
    if (abap.compare.initial(iv_proxy_host) === false) {
      lv_proxy.set(new abap.types.String().set(` via proxy <b>${abap.templateFormatting(iv_proxy_host)}:${abap.templateFormatting(iv_proxy_service)}</b>`));
    }
    rv_longtext.set(abap.operators.concat(new abap.types.String().set(`abapGit is trying to connect to <b>${abap.templateFormatting(iv_host)}</b> `),abap.operators.concat(new abap.types.String().set(`using SSL certificates under <b>${abap.templateFormatting(iv_ssl_id)}</b>${abap.templateFormatting(lv_proxy)}. `),abap.operators.concat(new abap.types.String().set(`Check system parameters (transaction `),abap.operators.concat((await (await abap.Classes['ZCL_ABAPGIT_HTML'].create()).get().zif_abapgit_html$a({iv_txt: abap.CharacterFactory.get(4, 'RZ10'), iv_act: new abap.types.String().set(`${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().jump_transaction)}?transaction=RZ10`), iv_class: abap.CharacterFactory.get(6, 'no-pad')})),abap.operators.concat(new abap.types.String().set(`), SSL setup (transaction `),abap.operators.concat((await (await abap.Classes['ZCL_ABAPGIT_HTML'].create()).get().zif_abapgit_html$a({iv_txt: abap.CharacterFactory.get(6, 'STRUST'), iv_act: new abap.types.String().set(`${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().jump_transaction)}?transaction=STRUST`), iv_class: abap.CharacterFactory.get(6, 'no-pad')})),abap.operators.concat(new abap.types.String().set(`), Internet connection monitor (transaction `),abap.operators.concat((await (await abap.Classes['ZCL_ABAPGIT_HTML'].create()).get().zif_abapgit_html$a({iv_txt: abap.CharacterFactory.get(5, 'SMICM'), iv_act: new abap.types.String().set(`${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().jump_transaction)}?transaction=SMICM`), iv_class: abap.CharacterFactory.get(6, 'no-pad')})),new abap.types.String().set(`)`))))))))));
    if (abap.compare.initial(lv_proxy) === false) {
      rv_longtext.set(abap.operators.concat(rv_longtext,abap.operators.concat(new abap.types.String().set(`, and proxy configuration (`),abap.operators.concat((await (await abap.Classes['ZCL_ABAPGIT_HTML'].create()).get().zif_abapgit_html$a({iv_txt: abap.CharacterFactory.get(15, 'global settings'), iv_act: new abap.types.String().set(`${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().go_settings)}`), iv_class: abap.CharacterFactory.get(6, 'no-pad')})),new abap.types.String().set(`)`)))));
    }
    rv_longtext.set(abap.operators.concat(rv_longtext,abap.operators.concat(new abap.types.String().set(`. It's recommended to get your SAP Basis and network teams involved. `),abap.operators.concat(new abap.types.String().set(`For more information and troubleshooting, see the `),abap.operators.concat((await (await abap.Classes['ZCL_ABAPGIT_HTML'].create()).get().zif_abapgit_html$a({iv_txt: abap.CharacterFactory.get(21, 'abapGit documentation'), iv_act: new abap.types.String().set(`${abap.templateFormatting(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_action.get().url)}?url=${abap.templateFormatting(lc_docs)}`), iv_class: abap.CharacterFactory.get(6, 'no-pad')})),new abap.types.String().set(`.`))))));
    return rv_longtext;
  }
  async get_http_client(INPUT) {
    return zcl_abapgit_http.get_http_client(INPUT);
  }
  static async get_http_client(INPUT) {
    let ri_client = new abap.types.ABAPObject({qualifiedName: "IF_HTTP_CLIENT", RTTIName: "\\INTERFACE=IF_HTTP_CLIENT"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lv_error = new abap.types.String({qualifiedName: "STRING"});
    let lv_longtext = new abap.types.String({qualifiedName: "STRING"});
    let lv_host = new abap.types.String({qualifiedName: "STRING"});
    let lv_ssl_id = new abap.types.Character(6, {"qualifiedName":"SSFAPPLSSL","ddicName":"SSFAPPLSSL","description":"SSL ID"});
    let lv_proxy_host = new abap.types.String({qualifiedName: "STRING"});
    let lv_proxy_service = new abap.types.String({qualifiedName: "STRING"});
    let lo_proxy_configuration = new abap.types.ABAPObject({qualifiedName: "ZCL_ABAPGIT_PROXY_CONFIG", RTTIName: "\\CLASS=ZCL_ABAPGIT_PROXY_CONFIG"});
    lo_proxy_configuration.set(await (new abap.Classes['ZCL_ABAPGIT_PROXY_CONFIG']()).constructor_());
    ri_client.set((await (await abap.Classes['ZCL_ABAPGIT_EXIT'].get_instance()).get().zif_abapgit_exit$create_http_client({iv_url: iv_url})));
    if (abap.compare.initial(ri_client)) {
      lv_host.set((await abap.Classes['ZCL_ABAPGIT_URL'].host({iv_url: iv_url})));
      lv_ssl_id.set((await (await abap.Classes['ZCL_ABAPGIT_EXIT'].get_instance()).get().zif_abapgit_exit$get_ssl_id()));
      lv_proxy_host.set((await lo_proxy_configuration.get().get_proxy_url({iv_repo_url: iv_url})));
      lv_proxy_service.set((await lo_proxy_configuration.get().get_proxy_port({iv_repo_url: iv_url})));
      lv_longtext.set((await this.get_connection_longtext({iv_host: lv_host, iv_ssl_id: lv_ssl_id, iv_proxy_host: lv_proxy_host, iv_proxy_service: lv_proxy_service})));
      try {
        await abap.Classes['CL_HTTP_CLIENT'].create_by_url({url: lv_host, ssl_id: lv_ssl_id, proxy_host: lv_proxy_host, proxy_service: lv_proxy_service, client: ri_client});
        abap.builtin.sy.get().subrc.set(0);
      } catch (e) {
        if (e.classic) {
            switch (e.classic.toUpperCase()) {
            case "ARGUMENT_NOT_FOUND": abap.builtin.sy.get().subrc.set(1); break;
            case "PLUGIN_NOT_ACTIVE": abap.builtin.sy.get().subrc.set(2); break;
            case "INTERNAL_ERROR": abap.builtin.sy.get().subrc.set(3); break;
            default: abap.builtin.sy.get().subrc.set(4); break;
              }
          } else {
              throw e;
          }
        }
        if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
          let unique237 = abap.builtin.sy.get().subrc;
          if (abap.compare.eq(unique237, abap.IntegerFactory.get(1))) {
            lv_error.set(abap.CharacterFactory.get(18, 'ARGUMENT_NOT_FOUND'));
          } else if (abap.compare.eq(unique237, abap.IntegerFactory.get(2))) {
            lv_error.set(abap.CharacterFactory.get(17, 'PLUGIN_NOT_ACTIVE'));
          } else if (abap.compare.eq(unique237, abap.IntegerFactory.get(3))) {
            lv_error.set(abap.CharacterFactory.get(14, 'INTERNAL_ERROR'));
          } else {
            lv_error.set(new abap.types.String().set(`OTHER_ERROR_${abap.templateFormatting(abap.builtin.sy.get().subrc)}`));
          }
          await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Error ${abap.templateFormatting(lv_error)} creating HTTP connection. Check the configuration`), iv_longtext: lv_longtext});
        }
      }
      if (abap.compare.eq((await lo_proxy_configuration.get().get_proxy_authentication({iv_repo_url: iv_url})), abap.builtin.abap_true)) {
        await abap.Classes['ZCL_ABAPGIT_PROXY_AUTH'].run({ii_client: ri_client});
      }
      return ri_client;
    }
    async is_local_system(INPUT) {
      return zcl_abapgit_http.is_local_system(INPUT);
    }
    static async is_local_system(INPUT) {
      let rv_bool = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
      let iv_url = INPUT?.iv_url;
      if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
      if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
      let lv_host = new abap.types.String({qualifiedName: "STRING"});
      let lt_list = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zif_abapgit_definitions=>ty_string_tt");
      let li_exit = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_EXIT", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_EXIT"});
      await abap.Classes['CL_HTTP_SERVER'].get_location({host: lv_host});
      abap.statements.append({source: lv_host, target: lt_list});
      abap.statements.append({source: abap.CharacterFactory.get(9, 'localhost'), target: lt_list});
      li_exit.set((await abap.Classes['ZCL_ABAPGIT_EXIT'].get_instance()));
      await li_exit.get().zif_abapgit_exit$change_local_host({ct_hosts: lt_list});
      abap.statements.find(iv_url, {regex: abap.CharacterFactory.get(18, 'https?://([^/^:]*)'), submatches: [lv_host]});
      abap.statements.readTable(lt_list,{withKey: (i) => {return abap.compare.eq(i.table_line, lv_host);},
        withKeyValue: [{key: (i) => {return i.table_line}, value: lv_host}],
        usesTableLine: true,
        withKeySimple: {"table_line": lv_host}});
      rv_bool.set(abap.builtin.boolc(abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))));
      return rv_bool;
    }
  }
  abap.Classes['ZCL_ABAPGIT_HTTP'] = zcl_abapgit_http;
  zcl_abapgit_http.c_scheme = new abap.types.Structure({
  "digest": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});
  zcl_abapgit_http.c_scheme.get().digest.set('Digest');
  zcl_abapgit_http.ty_key_value = new abap.types.Structure({
  "key": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-KEY"}),
  "value": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-VALUE"})}, "zcl_abapgit_http=>ty_key_value", undefined, {}, {});
  zcl_abapgit_http.ty_headers = abap.types.TableFactory.construct(new abap.types.Structure({
  "key": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-KEY"}),
  "value": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_HTTP=>TY_KEY_VALUE-VALUE"})}, "zcl_abapgit_http=>ty_key_value", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zcl_abapgit_http=>ty_headers");
export {zcl_abapgit_http};