Http_server: Ignore Accept-charset header

v3.3.4
gnosygnu 8 years ago
parent 5ff9b8d08a
commit 887724b536

@ -64,8 +64,8 @@ public class Gftest {
public static void Eq__str(String expd, String actl, String msg_fmt, Object... msg_args) {
if (String_.Eq(expd, actl)) return;
Write_fail_head(bfr, msg_fmt, msg_args);
bfr.Add_str_a7("expd: ").Add_str_u8(expd).Add_byte_nl();
bfr.Add_str_a7("actl: ").Add_str_u8(actl).Add_byte_nl();
bfr.Add_str_a7("expd: ").Add_str_u8_null(expd).Add_byte_nl();
bfr.Add_str_a7("actl: ").Add_str_u8_null(actl).Add_byte_nl();
bfr.Add(Bry__line_end);
throw Err_.new_wo_type(bfr.To_str_and_clear());
}

@ -84,6 +84,7 @@ public class Http_request_parser {
case Tid_pragma: this.pragma = Bry_.Mid(line, val_bgn, line_len); break;
case Tid_cache_control: this.cache_control = Bry_.Mid(line, val_bgn, line_len); break;
case Tid_origin: this.origin = Bry_.Mid(line, val_bgn, line_len); break;
case Tid_accept_charset: break;
default: throw Err_.new_unhandled(tid);
}
}
@ -146,7 +147,8 @@ public class Http_request_parser {
}
private String To_str() {return Make_request_itm().To_str(tmp_bfr, Bool_.N);}
private static final int Tid_get = 1, Tid_post = 2, Tid_host = 3, Tid_user_agent = 4, Tid_accept = 5, Tid_accept_language = 6, Tid_accept_encoding = 7, Tid_dnt = 8
, Tid_x_requested_with = 9, Tid_cookie = 10, Tid_referer = 11, Tid_content_length = 12, Tid_content_type = 13, Tid_connection = 14, Tid_pragma = 15, Tid_cache_control = 16, Tid_origin = 17;
, Tid_x_requested_with = 9, Tid_cookie = 10, Tid_referer = 11, Tid_content_length = 12, Tid_content_type = 13, Tid_connection = 14, Tid_pragma = 15, Tid_cache_control = 16
, Tid_origin = 17, Tid_accept_charset = 18;
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
.Add_str_int("GET" , Tid_get)
.Add_str_int("POST" , Tid_post)
@ -155,6 +157,7 @@ public class Http_request_parser {
.Add_str_int("Accept:" , Tid_accept)
.Add_str_int("Accept-Language:" , Tid_accept_language)
.Add_str_int("Accept-Encoding:" , Tid_accept_encoding)
.Add_str_int("Accept-Charset:" , Tid_accept_charset)
.Add_str_int("DNT:" , Tid_dnt)
.Add_str_int("X-Requested-With:" , Tid_x_requested_with)
.Add_str_int("Cookie:" , Tid_cookie)

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.net; import gplx.*; import gplx.core.*;
import org.junit.*;
import org.junit.*; import gplx.core.tests.*;
public class Http_request_parser_tst {
@Before public void init() {fxt.Clear();} private final Http_request_parser_fxt fxt = new Http_request_parser_fxt();
@Test public void Type_post() {
@ -47,15 +47,20 @@ public class Http_request_parser_tst {
, fxt.Make_post_data_itm("key1", "val1")
);
}
@Test public void Type_accept_charset() {
fxt.Test_ignore("Accept-Charset: ISO-8859-1,utf-8;q=0.7");
}
}
class Http_request_parser_fxt {
private final Http_request_parser parser;
private final Http_client_rdr client_rdr = Http_client_rdr_.new_mem();
private final Http_server_wtr__mock server_wtr = new Http_server_wtr__mock();
public Http_request_parser_fxt() {
this.parser = new Http_request_parser(Http_server_wtr_.Noop, false);
this.parser = new Http_request_parser(server_wtr, false);
}
public void Clear() {
parser.Clear();
server_wtr.Clear();
}
public Http_post_data_itm Make_post_data_itm(String key, String val) {return new Http_post_data_itm(Bry_.new_u8(key), Bry_.new_u8(val));}
public void Test_type_post(String line, int expd_type, String expd_url, String expd_protocol) {
@ -82,4 +87,9 @@ class Http_request_parser_fxt {
Tfds.Eq_bry(itm.Val(), expd[i].Val());
}
}
public void Test_ignore(String line) {
client_rdr.Stream_(String_.Ary(line));
parser.Parse(client_rdr);
Gftest.Eq__str(null, server_wtr.Data());
}
}

@ -17,6 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.net; import gplx.*; import gplx.core.*;
public class Http_server_wtr_ {
public static Http_server_wtr new_console() {return new Http_server_wtr__console();}
public static Http_server_wtr New__console() {return new Http_server_wtr__console();}
public static final Http_server_wtr Noop = new Http_server_wtr__noop();
}

@ -20,3 +20,8 @@ import gplx.core.consoles.*;
class Http_server_wtr__console implements Http_server_wtr {
public void Write_str_w_nl(String s) {Console_adp__sys.Instance.Write_str_w_nl(s);}
}
class Http_server_wtr__mock implements Http_server_wtr {
public void Write_str_w_nl(String s) {data = s;}
public String Data() {return data;} private String data;
public void Clear() {data = null;}
}

@ -48,7 +48,7 @@ public class Http_server_mgr implements Gfo_invk {
this.request_parser = new Http_request_parser(server_wtr, false);
}
public Xoae_app App() {return app;} private final Xoae_app app;
public Http_server_wtr Server_wtr() {return server_wtr;} private final Http_server_wtr server_wtr = Http_server_wtr_.new_console();
public Http_server_wtr Server_wtr() {return server_wtr;} private final Http_server_wtr server_wtr = Http_server_wtr_.New__console();
public Http_request_parser Request_parser() {return request_parser;} private final Http_request_parser request_parser;
public Gfo_url_encoder Encoder() {return encoder;} private final Gfo_url_encoder encoder = Gfo_url_encoder_.New__http_url().Make();
public int Port() {return port;} public Http_server_mgr Port_(int v) {port = v; return this;} private int port = 8080;

Loading…
Cancel
Save