mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.2.1'
This commit is contained in:
@@ -21,17 +21,17 @@ import gplx.core.primitives.*; import gplx.core.net.*; import gplx.langs.htmls.e
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.htmls.js.*;
|
||||
class Http_server_wkr_v2 implements GfoInvkAble {
|
||||
private final int uid;
|
||||
private final Http_server_mgr server_mgr;
|
||||
private final Http_server_wtr server_wtr;
|
||||
private final Http_client_wtr client_wtr = Http_client_wtr_.new_stream();
|
||||
private final Http_client_rdr client_rdr = Http_client_rdr_.new_stream();
|
||||
private final Http_request_parser request_parser;
|
||||
private final Gfo_url_encoder url_encoder;
|
||||
private final Xoae_app app;
|
||||
private final String root_dir_http;
|
||||
private final byte[] root_dir_fsys;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(64);
|
||||
private final int uid;
|
||||
private final Http_server_mgr server_mgr;
|
||||
private final Http_server_wtr server_wtr;
|
||||
private final Http_client_wtr client_wtr = Http_client_wtr_.new_stream();
|
||||
private final Http_client_rdr client_rdr = Http_client_rdr_.new_stream();
|
||||
private final Http_request_parser request_parser;
|
||||
private final Gfo_url_encoder url_encoder;
|
||||
private final Xoae_app app;
|
||||
private final String root_dir_http;
|
||||
private final byte[] root_dir_fsys;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(64);
|
||||
private Socket_adp socket;
|
||||
private Http_data__client data__client;
|
||||
public Http_server_wkr_v2(Http_server_mgr server_mgr, int uid){
|
||||
@@ -132,9 +132,9 @@ class Http_server_wkr_v2 implements GfoInvkAble {
|
||||
rv = Convert_page(rv, root_dir_http , "<<MISSING_WIKI>>");
|
||||
Xosrv_http_wkr_.Write_response_as_html(client_wtr, app_mode_itm.Tid() == Xoa_app_mode.Itm_file.Tid(), rv);
|
||||
}
|
||||
private static final byte[] Key__msg = Bry_.new_a7("msg"), Key__app_mode = Bry_.new_a7("app_mode");
|
||||
private static final byte[] Key__msg = Bry_.new_a7("msg"), Key__app_mode = Bry_.new_a7("app_mode");
|
||||
private static final int Tid_post_url_json = 1, Tid_post_url_gfs = 2;
|
||||
private static final Hash_adp_bry post_url_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry post_url_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_int("/exec/json" , Tid_post_url_json)
|
||||
.Add_str_int("/exec/gfs" , Tid_post_url_gfs)
|
||||
;
|
||||
@@ -152,19 +152,20 @@ class Http_server_wkr_v2 implements GfoInvkAble {
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_run = "run";
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Url__home = Bry_.new_a7("/"), Url__fsys = Bry_.new_a7("/fsys/")
|
||||
, Url__exec = Bry_.new_a7("/exec/"), Url__exec_2 = Bry_.new_a7("/xowa-cmd:")
|
||||
;
|
||||
private static final int Url__fsys_len = Url__fsys.length;
|
||||
private static final int Url__fsys_len = Url__fsys.length;
|
||||
}
|
||||
class Xosrv_http_wkr_ {
|
||||
public static void Write_response_as_html(Http_client_wtr client_wtr, boolean cross_domain, String html) {Write_response_as_html(client_wtr, cross_domain, Bry_.new_u8(html));}
|
||||
public static void Write_response_as_html(Http_client_wtr client_wtr, boolean cross_domain, byte[] html) {
|
||||
try{
|
||||
client_wtr.Write_bry(Rsp__http_ok);
|
||||
if (cross_domain)
|
||||
client_wtr.Write_str("Access-Control-Allow-Origin: *\n"); // No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
||||
// TODO: add command-line argument to allow testing from local file
|
||||
// if (cross_domain)
|
||||
// client_wtr.Write_str("Access-Control-Allow-Origin: *\n"); // No 'Access-Control-Allow-Origin' header is present on the requested resource.
|
||||
client_wtr.Write_bry(Rsp__content_type_html);
|
||||
client_wtr.Write_bry(Byte_ascii.Nl_bry);
|
||||
client_wtr.Write_bry(html);
|
||||
@@ -173,7 +174,7 @@ class Xosrv_http_wkr_ {
|
||||
client_wtr.Rls();
|
||||
}
|
||||
}
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Rsp__http_ok = Bry_.new_a7("HTTP/1.1 200 OK:\n")
|
||||
, Rsp__content_type_html = Bry_.new_a7("Content-Type: text/html; charset=utf-8\n")
|
||||
;
|
||||
@@ -187,7 +188,7 @@ class Http_file_utl {
|
||||
Object o = mime_hash.Get_by_mid(ext_bry, bgn, end);
|
||||
return o == null ? Mime_octet_stream : (byte[])o;
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Mime_html = Bry_.new_a7("text/html")
|
||||
, Mime_jpg = Bry_.new_a7("image/jpeg")
|
||||
, Mime_png = Bry_.new_a7("image/png")
|
||||
@@ -196,7 +197,7 @@ class Http_file_utl {
|
||||
, Mime_js = Bry_.new_a7("application/javascript")
|
||||
, Mime_octet_stream = Bry_.new_a7("application/octet-stream")
|
||||
;
|
||||
private static final Hash_adp_bry mime_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry mime_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_obj(".htm" , Mime_html)
|
||||
.Add_str_obj(".html" , Mime_html)
|
||||
.Add_str_obj(".jpg" , Mime_jpg)
|
||||
|
||||
Reference in New Issue
Block a user