function java_http_set_options(j_conn, options)
        % input
        %   j_conn  - java connection type, returned by javaMethod('openConnection',j_url)
        %   options - class structure, returned by weboptions_java
        %
        % output
        %   none
        % 
        % 
        % See Also java_http_request, weboptions_java, webwrite_java
        %
        
        % method
        if ~isempty(options.RequestMethod)
            javaMethod('setRequestMethod', j_conn, upper(options.RequestMethod));
        end
        
        % Authorization wasn't implemented yet
        if ~isempty(options.Username) && ~isempty(options.Password)
            warning('Authorization wasn''t implemented yet\n');
        end
        
        % key-value (headers)
        if ~isempty(options.HeaderFields)
            h_names  = options.HeaderFields(1:2:end); 
            h_values = options.HeaderFields(2:2:end);
            
            for i = 1:length(h_names)
                javaMethod('setRequestProperty', j_conn, h_names{i}, h_values{i});
            end
        end
        
        % Timeout
        javaMethod('setReadTimeout',    j_conn, options.Timeout*1000); %timeout value in milliseconds
        javaMethod('setConnectTimeout', j_conn, options.Timeout*1000);
end