Ignore:
Timestamp:
2011-05-19T13:38:12+12:00 (13 years ago)
Author:
sjm84
Message:

The hhf cgi parameter is now implemented using JSON, also a few other minor commits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r24019 r24052  
    1515import java.util.ArrayList;
    1616import java.util.HashMap;
     17import java.util.List;
     18import java.util.Map;
    1719import java.io.File;
     20import java.lang.reflect.Type;
    1821import java.util.Hashtable;
    1922import org.apache.log4j.*;
     23
     24import com.google.gson.Gson;
     25import com.google.gson.reflect.TypeToken;
    2026
    2127// Apache Commons
     
    560566       
    561567        //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++)
    567574            {
    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");
    569578               
    570                 if(index != -1)
     579                System.err.println("SETTING HEADER " + name + " = " + value);
     580               
     581                if(name != null && value != null)
    571582                {
    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            }
    576586        }
    577587       
     
    689699       
    690700    }
    691 
    692701}
Note: See TracChangeset for help on using the changeset viewer.