Changeset 24052 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Timestamp:
- 2011-05-19T13:38:12+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r24019 r24052 15 15 import java.util.ArrayList; 16 16 import java.util.HashMap; 17 import java.util.List; 18 import java.util.Map; 17 19 import java.io.File; 20 import java.lang.reflect.Type; 18 21 import java.util.Hashtable; 19 22 import org.apache.log4j.*; 23 24 import com.google.gson.Gson; 25 import com.google.gson.reflect.TypeToken; 20 26 21 27 // Apache Commons … … 560 566 561 567 //Add custom HTTP headers if requested 562 String httpHeaders = StringEscapeUtils.unescapeHtml4(request.getParameter(GSParams.HTTPHEADERFIELDS)); 563 if (httpHeaders!=null && !httpHeaders.equals ("")) { 564 String[] headerParams = StringUtils.split(httpHeaders, "&"); 565 566 for(int j = 0; j < headerParams.length; j++) 568 Gson gson = new Gson(); 569 Type type = new TypeToken<List<Map<String,String>>>() {}.getType(); 570 List<Map<String,String>> httpHeaders = gson.fromJson(request.getParameter(GSParams.HTTPHEADERFIELDS), type); 571 if (httpHeaders != null && httpHeaders.size() > 0) { 572 573 for(int j = 0; j < httpHeaders.size(); j++) 567 574 { 568 int index = StringUtils.indexOf(headerParams[j], "="); 575 Map nameValueMap = (Map)httpHeaders.get(j); 576 String name = (String)nameValueMap.get("name"); 577 String value = (String)nameValueMap.get("value"); 569 578 570 if(index != -1) 579 System.err.println("SETTING HEADER " + name + " = " + value); 580 581 if(name != null && value != null) 571 582 { 572 response.setHeader(StringUtils.substring(headerParams[j], 0, index), StringUtils.substring(headerParams[j], index+1)); 573 } 574 } 575 583 response.setHeader(name, value); 584 } 585 } 576 586 } 577 587 … … 689 699 690 700 } 691 692 701 }
Note:
See TracChangeset
for help on using the changeset viewer.