我正在对jMeter进行测试,但我遇到了以下问题:在执行与浏览器相同的请求后,与实际浏览器相比,我在响应中收到的cookie更少。我认为这个问题会影响我的项目,因为还存在缺少cookie的登录请求。
我正在使用Cookie管理器,它可以在存储时正确保存和发送Cookie。
我还在网络上建议将- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
[locationManager requestWhenInUseAuthorization];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
MKPointAnnotation *myAnnotation = [[MKPointAnnotation alloc]init];
CLLocationCoordinate2D pinCoordinate;
pinCoordinate.latitude = 51.49795;
pinCoordinate.longitude = -0.174056;
myAnnotation.coordinate = pinCoordinate;
myAnnotation.title = @"Matthews Pizza";
myAnnotation.subtitle = @"Best Pizza in Town";
[self.mapKit addAnnotation:myAnnotation];
// myAnnotation.coordinate = CLLocationCoordinate2DMake(51.49795, -0.174056);
// Do any additional setup after loading the view.
}
-(void)checkStatus{
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status==kCLAuthorizationStatusNotDetermined) {
NSLog(@"Not Determined");
}
if (status==kCLAuthorizationStatusDenied) {
NSLog(@"Denied");
}
if (status==kCLAuthorizationStatusRestricted) {
NSLog(@"Restricted");
}
if (status==kCLAuthorizationStatusAuthorizedAlways) {
NSLog(@"Always Allowed");
}
if (status==kCLAuthorizationStatusAuthorizedWhenInUse) {
NSLog(@"NWhen In Use Allowed");
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)viewWillAppear:(BOOL)animated{
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapKit setRegion:[self.mapKit regionThatFits:region] animated:YES];
}
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:@"Error" message:@"Failed to Get Your Location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]);
NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]);
}
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// If it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// Handle any custom annotations.
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
// Try to dequeue an existing pin view first.
MKAnnotationView *pinView = (MKAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"CustomPinAnnotationView"];
if (!pinView)
{
// If an existing pin view was not available, create one.
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"CustomPinAnnotationView"];
pinView.canShowCallout = YES;
pinView.image = [UIImage imageNamed:@"ic_map"];
pinView.calloutOffset = CGPointMake(0, 32);
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
} else {
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
id <MKAnnotation> annotation = [view annotation];
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
NSLog(@"Clicked Pizza Shop");
}
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Disclosure Pressed" message:@"Click Cancel to Go Back" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alertView show];
}
字符串添加到CookieManager.save.cookies=true
文件中。
如果它可以提供帮助,我几乎不会收到一些名为users.properties
的cookie,以及一个名为ADRUM
的cookie。
感谢您的建议。
答案 0 :(得分:2)
我设法通过更改HTTP Cookie管理器策略来解决此问题。有关详细信息,请参阅文档here。
编辑:我忘了说我已将政策切换为default
答案 1 :(得分:0)
添加到user.properties:
CookieManager.check.cookies =真
JMeter默认验证cookie与您的域匹配,而不保存其他域。 参见: