Giter Club home page Giter Club logo

asi-http-request's People

Contributors

0xced avatar adamwulf avatar aidansteele avatar andyfowler avatar arix avatar atnan avatar cocoabits avatar greenisus avatar ikarius avatar jogu avatar jverkoey avatar jweyrich avatar leereilly avatar lhunath avatar lolsborn avatar lukeredpath avatar metaskills avatar mihaidamian avatar nanotech avatar pjay avatar pokeb avatar rbsgn avatar schmidp avatar soffes avatar steipete avatar timshadel avatar tomandersen avatar v01dzer0 avatar yllan avatar zwaldowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asi-http-request's Issues

ASIHTTPRequest wont cancel when it is downloading data

I noticed strange thing with ASIHTTPRequest when it downloads ~50Kb image over slow cellular connection. In my code I configure ASIHTTPRequest to download ~50Kb image over cellular network. When user wants to cancel the download I send -[NSOperationQueue cancelAllOperations] to cancel the request. ASIHTTPRequest's delegate receives requestDidFailed: message with ASIRequestCancelledErrorType error. But afterwards delegate receives requestDidFinished: message with properly downloaded image. To workaround this issue I send -[ASIHTTPRequest cancel] in requestDidFailed: if request failed with error ASIRequestCancelledErrorType.

I think it's a bug.

S3 requests take path - which is NOT the S3 key, - Leading '/' problem

The paths that S3 requests take is not the key that amazon uses to store the data. The path needs a prefix of / , ie path == /key
This does not seem to be in the docs, and may even be a bug. At the least there should be an assertion added to requestWithBucket. It seems dumb to repair the 'path'. Perhaps renaming the call, (which breaks existing stuff) or making a new call, like requestWithBucket:(NSString_)bucket key:(NSString_)key would be better.

  • (id)requestWithBucket:(NSString *)bucket path:(NSString *)path
    {
    if (![path hasPrefix:@"/"])
    {
    // either fix the path, or assert, or both
    NSLog(@"The path passed must start with /, passed path was %@", path);
    path = [@"/" stringByAppendingString:path];
    }

ASIS3Request *request = [[[self alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@.s3.amazonaws.com%@",bucket,path]]] autorelease];
[request setBucket:bucket];
[request setPath:path];
return request;
}

Fails to build on fresh checkout.

Both the sample projects use a build script to set the version number post build. This refers to stuff not installed by default on Mac OS X thus causing the build to error out. Deleting the build script phase allows the build to complete.

uploadProgressDeleagate called instead of downloadProgressDelegate in ASIHTTPRequest

ASIHTTPRequest.m:1382

- (void)incrementDownloadSizeBy:(long long)length
{
    [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:[self queue] withObject:self amount:&length];
-   [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:[self uploadProgressDelegate] withObject:self amount:&length];
+   [ASIHTTPRequest performSelector:@selector(request:incrementDownloadSizeBy:) onTarget:[self downloadProgressDelegate] withObject:self amount:&length];
 }

initWithURL: should call [self init] rather than [super init]

You need to call self here or ASIHTTPRequest subclasses can't configure defaults by overriding -init. I haven't checked other areas of the code, but generally super should never be called unless it's from the same method implementation in a subclass.

memory leaks with garbage collection

If I run 'build and analyze' on a garbage-collection-enabled project using ASIHTTPRequest, I get 10 warnings with the message "Potential leak (when using garbage collection) of an object..." (in ASIFormDataRequest.m and ASIHTTPRequest.m). Could you look into this? (It seems it's mostly related to objects allocated using CoreFoundation functions and deallocated using autorelease.)

[PATCH] Properly encoding form data + setting correct character set header.

The following patch adds proper URL encoding of form data to ASIFormDataRequest. It also sets the charset to UTF-8, the charset that is used throughout ASIFormDataRequest to encode strings into data.

Without the former, URL injection is easily possible and people could just pass maliciously crafted data to an application to forge an incorrect request.

Without the latter many servers misinterprete the form data as ISO-8859-1 and certain characters get manhandled.

diff --git a/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.h b/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.h
index a0991ad..dbc73ed 100644
--- a/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.h
+++ b/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.h
@@ -26,6 +26,9 @@ typedef enum _ASIPostFormat {
    ASIPostFormat postFormat;
 }

+#pragma mark utilities 
++ (NSString*) encodeURL:(CFStringRef) string; 
+ 
 #pragma mark setup request

 // Add a POST variable to the request
diff --git a/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.m b/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.m
index 803cf33..29c7827 100644
--- a/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.m
+++ b/device/iphone/safe-online-iphone-client/Sources/ASIHttpRequest/Classes/ASIFormDataRequest.m
@@ -19,6 +19,17 @@

 @implementation ASIFormDataRequest

+#pragma mark utilities
++ (NSString*) encodeURL:(CFStringRef)string
+{
+   CFStringRef result = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
+                                                                 string,
+                                                                 NULL,
+                                                                 CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"),
+                                                                 kCFStringEncodingUTF8);
+   return [(NSString*) result autorelease];
+}
+
 #pragma mark init / dealloc

 + (id)requestWithURL:(NSURL *)newURL
@@ -181,7 +192,7 @@
        return;
    }

-   [self addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];
+   [self addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded; charset=UTF-8"];


    NSEnumerator *e = [[self postData] keyEnumerator];
@@ -189,7 +200,7 @@
    int i=0;
    int count = [[self postData] count]-1;
    while (key = [e nextObject]) {
-       NSString *data = [NSString stringWithFormat:@"%@=%@%@",[key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[[[self postData] objectForKey:key] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],(i<count ? @"&" : @"")];
+       NSString *data = [NSString stringWithFormat:@"%@=%@%@", [ASIFormDataRequest encodeURL:(CFStringRef)key], [ASIFormDataRequest encodeURL:(CFStringRef)[[self postData] objectForKey:key]],(i<count ?  @"&" : @"")]; 
        [self appendPostData:[data dataUsingEncoding:NSUTF8StringEncoding]];
        i++;
    }

reachability 2.0 support

apple has updated its reachability class to version 2.0 which currently breaks ASIHTTPRequest

iPhone download performance.

I don't know if anyone else has experience this but I'm seeing a large performance hit when running the code on an Iphone 3G. (On WiFi.) I got about 30 kbit/s

The same code running on the simulator runs at 200 kbit/s (My maximum line speed.)

Crash when incorrect credentials are sent

I'm setting the credentials with using setUserName and setPassword in the delegate method authenticationNeededForRequest. If credentials are wrong the app crashes.

It looks like the authentication delegate method is being called 3 times before the crash occurs, and from what I understand from the code this shouldn't be happening, and the request should just fail if the authorisation attempt count is 2.

The crash occurs on the line "[self setRequestCredentials:nil];" in ASIHTTPRequest's "attemptToApplyCredentials".

I have an example app if necessary.

Download Progress shouldn't be updated with redirecting URLs

When fetching an URL that gets redirected, de progress is set to 100% when the redirecting request finished. Then the progress is set back again to 0% when the new request (to which the other URL pointed) is started.

Better would be not to set the progress, until the headers are processed and it is known that the request is not redirected.

Redirecting to URL with explicit port causes request to fail

In my test example, I'm requesting a URL, say:

http://example.com/foo

Which redirects to:

http://example.com:80/foo

This fails because an exception is thrown deep in the guts of ASIHTTPRequest. I tracked this down to line 2904 of ASIHTTPRequest.m in the method findSessionAuthenticationCredentials, where it tries to compare the port of the new URL (80) to the port in the original URL (nil). The exception is thrown because it is calling NSNumber isEqualToNumber: with a nil argument.

So, this line:

        if ([[theURL host] isEqualToString:[requestURL host]] && ([theURL port] == [requestURL port] || [[theURL port] isEqualToNumber:[requestURL port]]) && [[theURL scheme] isEqualToString:[requestURL scheme]]) {

Should probably be something like (ugly, but works):

        if ([[theURL host] isEqualToString:[requestURL host]] && ([theURL port] == [requestURL port] || ([requestURL port] && [[theURL port] isEqualToNumber:[requestURL port]])) && [[theURL scheme] isEqualToString:[requestURL scheme]]) {

iOS4 - problems with authentificaiton dialog

In iOS 4, the authentication dialog does not seem to work, its shown as expected, but it isn't possible to write a username or password into it.
The keyboard appears, it is possible to select a textfield aswell, but the input doesn't seem to reach the textField.

S3 upload file missing data on device, but not on simulator

I'm experiencing an issue with an Amazon S3 file upload. The simulator works great. But the exact same code on the device doesn't seem to upload the entire 166 Kb .png picture file. It only seems to upload 159 Kb. When I try to open the image, I get an error. I've tried both 3G network and WiFi. Both with the same result. Anyone experienced this issue or know what the problem could be? I am on an iPhone 3Gs running OS 3.1.

10.6 API used

This may not be a bug and it may be the intention that ASIHTTPRequest is targeting 10.6 only now but line 3458 of ASIHTTPRequest.m calls:

  • (id)dateByAddingTimeInterval:(NSTimeInterval)seconds

Which is a 10.6 API.

Downloading redirected URL + Temp file doesn't work

When using a redirected URL and a custom temp file, the output stream is being closed when the stream from the redirecting URL is completed, in line 2500:

if ([self temporaryFileDownloadPath]) {
    [[self fileDownloadOutputStream] close];

After that, the final URL starts to download to a closed output stream (fileDownloadOutputStream).

iPhone Sample QueueViewController Image loading works on Simulator but not on Device

Hi!

I've noticed a bug in the sample project.
When I build the sample project and run on the Simulator everything is in order, all URL request works. But when I try to run this project on an iPhone I noticed when try to run the Queue sample (2. tab) it never finish the downloading and never show any images!

I found a workaround, read below:

QueueViewController.m (iPhone.xcode)

  • (IBAction)fetchThreeImages:(id)sender
    {
    .
    .
    .
    ASIHTTPRequest *request;
    request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/images/small-image.jpg"]];
    [request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"1.png"]];
    [networkQueue addOperation:request];

In this section the download destination path points to the Application's root directory which is writeable on the Simulator but not on Device (the device throws a write deny message, but this message only shows in the device log only not in the debugger console). So I changed the download destination to CachedImages below the NSCachesDirectory which is writeable on the Device

Regards,

Body of an redirecting URL gets written and body of final URL gets appended to it

Hi again,

When using ASIHTTPRequest to download redirected URLs (e.g. 307, temporary redirect), the body of the redirecting URL gets saved to file (or memory). In my test case (http://download.omroep.nl/vpro/35551406.mp3), the redirecting URL's body contains html meta redirect code (as fallback for browsers ignoring the 307 HTTP status).

It seems to be solved when this condition is added at line 2478 in ASIHTTPRequest.m. Not sure if there are any malicious consequences though...

if ([self needsRedirect] == NO) 
    // Are we downloading to a file?
    if ([self downloadDestinationPath])

M

iPhone 3.1 and FileUpload

Been using the File upload for quite some time and every since 3.1 came out on the iPhone I get the error "Domain=ASIHTTPRequestErrorDomain Code = 1 UserInfo == xxxx 'A connection failure occurred: SSL problem (possibly a bad/expired/self-signed certificate)'"

Our hosting provider assures us all is good on the cert/config areas.

This is totally random and when I am good 3G coverage. I can immediately retry and it may or may not work. Not sure if this is an issue in the ASI code just wanted to toss it out there in case anyone else is having this.

Original URL not stored after redirect

It would be nice if the request would store the original URL.
When using a queue and requestDidFinish delegate methods, I usually check the url property of a request to figure out which resource has been downloaded. But if the request has been redirected, this fails.

responseString returns nil and responseData returns data

The issue is with the following url and any url after this (replace the 100 with 200, 300, 400, etc):
http://www.craigslist.org/about/best/all/index100.html

The first page of the 'best of' section (http://www.craigslist.org/about/best/all/) works fine. For all other pages responseString returns nil due to trying to convert the responseData (which is properly downloaded) with the wrong encoding. ASI tries to use UTF8 when the actual data is ASCII (or at least using NSASCIIStringEncoding will allow the data to be converted to string).

This may or may not be an ASI issue. I will see if I can get some more info and a fix or if it is just a craigslist.org issue with sending different encoding and actual data.

KVO notifications badly ordered in markAsFinished

- (void)markAsFinished
 {
    [self willChangeValueForKey:@"isFinished"];
    [self didChangeValueForKey:@"isFinished"];
    [self setInProgress:NO];
    CFRunLoopStop(CFRunLoopGetCurrent());
}

should be

- (void)markAsFinished
{
    [self willChangeValueForKey:@"isFinished"];
    [self setInProgress:NO];
    [self didChangeValueForKey:@"isFinished"];
    CFRunLoopStop(CFRunLoopGetCurrent());
}

I'm seeing a EXC_BAD_ACCESS when I run through this code. I'm not aware that this defect would cause that though.

No Progress for ASIS3Request's queued in ASINetworkQueue

I've setup multiple ASIS3Request's and added them to a ASINetworkQueue.
The S3 Requests have a download and temporary download path, resume download is allowed.

I've setup a UIProgressView as downloadProgressDelegate for the queue.

However it seems that the progress is not updated.
I've debugged the methods:

  • (void)incrementDownloadSizeBy:(unsigned long long)bytes
    and
  • (void)incrementDownloadProgressBy:(unsigned long long)bytes
    in the ASINetworkQueue class and both times the "bytes" value passed to these methods is 0.

Any ideas how to solve this?

immediateCancel test is failing

In the right circumstances, the same request is able to call both its success and failure delegate methods, this shouldn't be possible. Must have been broken as a result of recent changes.

ASINetworkQueue won't run (actually restart)

Hi, I've got a singleton method that I use to manage downloading.

I'm downloading a lot of files so they are placed in a ASINetworkQueue and run.

All works well until after the user chooses to cancel download (I call a cancelAllOperations on the queue) and the queue is cancelled.

However if the user chooses to start the download again I see the queue fill up with requests, I then call "go" but nothing happens.

The ASINetworkQueue object is retained and still exists (hence the fact I can get a count). It just never runs the second time.

Any ideas?

Thanks, M

warnings during compilation

When I compile my application which uses ASIHTTPRequest, I get two warnings with such message:

incompatible Objective-C types assigning 'struct NSDictionary *', expected 'struct NSMutableDictionary *'

Both are reported in ASIHTTPRequest.m, one on @synthesize proxyCredentials and the other on @synthesize requestCredentials. It's not really a problem, but it is a bit annoying to see this every time I recompile the app ;)

Internal compiler error: Segmentation fault

I receive the error "Internal compiler error: Segmentation fault" when attempting to build a project which includes asi-http-request. Pressing build again usually alleviates this error, but it is still quite annoying. This occurs on both my Macbook Pro, Macbook Air, and Mac Pro. Thanks for your help!

readStream null on occasion

I don't have really good reproduce instructions for you on this one because it is so rare but it does happen. I use a standard NSOperationQueue to push all ASIHTTPRequests into and I push a lot of requests through it limited to 4 simulataneously.

Around line 717 of ASIHTTPRequest.m there are (rare) occasions when the readStream is NULL and
the following line crashes the app:

[self setTotalBytesSent:[[(NSNumber *)CFReadStreamCopyProperty(readStream, kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease] unsignedLongLongValue]];

Timed retries?

Hi,

I noticed that it's possible to configure ASIHTTPRequest to automatically retry a set number of times. But it seems that to retry immediately after it has failed. I think an (exponentially growing) delay between the failed attempt and the next attempt would be better.

M

Little bug in line 1739 of ASIHTTPRequest.m

Little bug in line 1739 of ASIHTTPRequest.m:

NSLog(@"Request will redirect (code: %hi): %@", self, [self responseStatusCode]);

Should be:

NSLog(@"Request will redirect (code: %hi): %@", [self responseStatusCode], self);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.