IHS作为web server,因为上传Base64图片流,如果url过长报错:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>414 Request-URI Too Long</title>
</head>
<body>
<h1>Request-URI Too Long</h1>
<p>The requested URL's length exceeds the capacity limit for this server.</p>
</body>
</html>
修改Apache的httpd.conf配置文件中添加
LimitRequestLine 4000000 LimitRequestFieldSize 4000000
LimitRequestLine 4000000 //Limit the size of the HTTP request line that will be accepted from the client
客户端发送的HTTP请求行的最大字节数【默认 8190】,请求行包括HTTP方法、URL、协议版本等,因此LimitRequestLine指令能够限制URL的长度,服务器会需要这个值足够大以装载它所有的资源名,包括可能在GET请求中所传递的查询部分的所有信息
LimitRequestFieldSize 4000000 //Limits the size of the HTTP request header allowed from the client
限制客户端发送的请求头的字节数 【默认 8190】,
LimitRequestBody 4000000 //Restricts the total size of the HTTP request body sent from the client
http请求包含(请求行,请求头,请求体)
参考:https://www.jianshu.com/p/eb3e5ec98a66
https://www.jianshu.com/p/eb3e5ec98a66
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HttpURLConnect调用URL关闭,一直调用卡住不动。只用connect timeout,没有read timeout
connect timeout 是建立连接的超时时间;
read timeout,是传递数据的超时时间。
1 public String getConn(String str) { 2 String url = ""; 3 String validateResult = null; 4 HttpURLConnection con = null; 5 BufferedInputStream bis = null; 6 if(TypeChecker.isEmpty(url)) { 7 system.out.println("URL NULL!"); 8 return null; 9 } 10 try { 11 URL dataUrl = new URL(url); 12 con = (HttpURLConnection) dataUrl.openConnection(); 13 system.out.println("url ="+url); 14 system.out.println("postData ="+str); 15 con.setRequestMethod("POST"); 16 con.setRequestProperty("Content-Type","text/xml;charset=utf-8"); 17 con.setDoOutput(true); 18 con.setDoInput(true); 19 con.setAllowUserInteraction(false); 20 con.setUseCaches(false); 21 con.setConnectTimeout(30*1000); 22 con.setReadTimeout(30*1000); 23 24 OutputStream os=con.getOutputStream(); 25 DataOutputStream dos=new DataOutputStream(os); 26 dos.write(str.getBytes()); 27 dos.flush(); 28 dos.close(); 29 int code = con.getResponseCode(); 30 system.out.println("resultCode================:"+code); 31 if (!TypeChecker.isEmpty(code)&&(code == 200||code == 201||code == 202)) { 32 bis = new BufferedInputStream(con.getInputStream()); 33 } else { 34 system.out.println("can not connect URL ,result NULL!"); 35 return null; 36 } 37 38 bis = new BufferedInputStream(con.getInputStream()); 39 BufferedReader br = new BufferedReader(new InputStreamReader(bis, "UTF-8")); 40 String result = ""; 41 String readLine = ""; 42 while ((readLine = br.readLine()) != null) { 43 if (readLine.length() > 0) 44 result += readLine; 45 } 46 system.out.println("result:"+result); 47 if (result != null && result.length() > 0){ 48 validateResult = result; 49 }else{ 50 system.out.println("result NULL!"); 51 return null; 52 } 53 } catch (Exception ex) { 54 system.out.println("receive Exception: " + ex.getMessage()); 55 ex.printStackTrace(); 56 return null; 57 }finally{ 58 if (bis != null) 59 try { 60 bis.close(); 61 } catch (IOException e) { 62 // TODO Auto-generated catch block 63 e.printStackTrace(); 64 } 65 if(con != null) 66 con.disconnect(); 67 } 68 return validateResult; 69 }
参考:https://blog.csdn.net/weixin_33720452/article/details/87625209
https://blog.csdn.net/q2232/article/details/48136973
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- List list = xxxService.getAll();
- for(Object obj : list ){
- list.remove(obj ); //此方式必然导致ConcurrentModificationException
- }
- List list = xxxService.getAll();
- for(Iterator objIter = list.iterate();obj.hasNext(); ){
- list.remove(obj ); //此方式也导致ConcurrentModificationException
- }
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
at java.util.LinkedList$ListItr.next(Unknown Source)
- List list = xxxService.getAll();
- for(Iterator objIter = list.iterate();obj.hasNext(); ){
- objIter .remove();
- }