use of org.apache.jmeter.protocol.http.control.CookieManager in project jmeter by apache.
the class AjpSampler method getHeaderSize.
private int getHeaderSize(String method, URL url) {
HeaderManager headers = getHeaderManager();
CookieManager cookies = getCookieManager();
AuthManager auth = getAuthManager();
// Host always
int hsz = 1;
if (method.equals(HTTPConstants.POST)) {
HTTPFileArg[] hfa = getHTTPFiles();
if (hfa.length > 0) {
hsz += 3;
} else {
hsz += 2;
}
}
if (headers != null) {
hsz += headers.size();
}
if (cookies != null) {
hsz += cookies.getCookieCount();
}
if (auth != null) {
String authHeader = auth.getAuthHeaderForURL(url);
if (authHeader != null) {
++hsz;
}
}
return hsz;
}
use of org.apache.jmeter.protocol.http.control.CookieManager in project jmeter by apache.
the class CookiePanel method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if (action.equals(DELETE_COMMAND)) {
if (tableModel.getRowCount() > 0) {
// If a table cell is being edited, we must cancel the editing
// before deleting the row.
GuiUtils.cancelEditing(cookieTable);
if (cookieTable.getRowCount() > 0) {
int rowSelected = cookieTable.getSelectedRow();
if (rowSelected < 0) {
rowSelected = 0;
}
tableModel.removeRow(rowSelected);
tableModel.fireTableDataChanged();
// Disable the DELETE and SAVE buttons if no rows remaining
// after delete.
configureButtonsState();
if (tableModel.getRowCount() > 0) {
// Table still contains one or more rows, so highlight
// (select) the appropriate one.
int rowToSelect = rowSelected;
if (rowSelected >= tableModel.getRowCount()) {
rowToSelect = rowSelected - 1;
}
cookieTable.setRowSelectionInterval(rowToSelect, rowToSelect);
}
}
}
} else if (action.equals(ADD_COMMAND)) {
// If a table cell is being edited, we should accept the current
// value and stop the editing before adding a new row.
GuiUtils.stopTableEditing(cookieTable);
tableModel.addNewRow();
tableModel.fireTableDataChanged();
configureButtonsState();
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
cookieTable.setRowSelectionInterval(rowToSelect, rowToSelect);
} else if (action.equals(LOAD_COMMAND)) {
try {
//$NON-NLS-1$
final String[] _txt = { ".txt" };
final JFileChooser chooser = FileDialoger.promptToOpenFile(_txt);
if (chooser != null) {
CookieManager manager = new CookieManager();
manager.addFile(chooser.getSelectedFile().getAbsolutePath());
for (int i = 0; i < manager.getCookieCount(); i++) {
addCookieToTable(manager.get(i));
}
tableModel.fireTableDataChanged();
configureButtonsState();
}
} catch (IOException ex) {
log.error("", ex);
}
} else if (action.equals(SAVE_COMMAND)) {
try {
//$NON-NLS-1$
final JFileChooser chooser = FileDialoger.promptToSaveFile("cookies.txt");
if (chooser != null) {
((CookieManager) createTestElement()).save(chooser.getSelectedFile().getAbsolutePath());
}
} catch (IOException ex) {
JMeterUtils.reportErrorToUser(ex.getMessage(), "Error saving cookies");
}
}
}
use of org.apache.jmeter.protocol.http.control.CookieManager in project jmeter by apache.
the class CookiePanel method configure.
@Override
public void configure(TestElement el) {
super.configure(el);
CookieManager cookieManager = (CookieManager) el;
populateTable(cookieManager);
clearEachIteration.setSelected((cookieManager).getClearEachIteration());
// must set policy after setting handler (which may change the policy)
policy.setText(cookieManager.getPolicy());
}
Aggregations