Code Monkey home page Code Monkey logo

urlmock's People

Contributors

danielrhammond avatar flightblog avatar igorpakushin avatar jnjosh avatar prachigauriar avatar slavikus avatar snf-tms avatar tomburns avatar z3bi 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

urlmock's Issues

Cannot find support for XML encoding?

I can see following supported:
NSString *const kUMKMockHTTPMessageJSONContentTypeHeaderValue = @"application/json";
NSString *const kUMKMockHTTPMessageUTF8JSONContentTypeHeaderValue = @"application/json; charset=utf-8";
NSString *const kUMKMockHTTPMessageWWWFormURLEncodedContentTypeHeaderValue = @"application/x-www-form-urlencoded";
NSString *const kUMKMockHTTPMessageUTF8WWWFormURLEncodedContentTypeHeaderValue = @"application/x-www-form-urlencoded; charset=utf-8";

expectMockHTTPPostRequestWithURL does not set content type

    [UMKMockURLProtocol expectMockHTTPPostRequestWithURL:URL requestJSON:requestJSON responseStatusCode:200 responseJSON:responseJSON];

If I am setting JSON as POST body and expecting JSON response should the framework also set the content-type header to 'application/json'?

Simple cut and paste from your example does not work as the content-type is not set correctly. Should the content-type be set automatically when I say that I posting JSON and expecting JSON back?

- (BOOL)bodyMatchesBodyOfURLRequest:(NSURLRequest *)request

That is the method that fails to match the body in the case of content-type 'application/json
not being set.

Thoughts?

Library still isn't called HolyMockURL

Summary:

This library is pretty cool and all, but it needs a name that is just as cool.

Steps to Reproduce:

  1. Look at library
  2. See that its name is somewhat lacking

Expected Results:

Expected this to have a badass name like HolyMockURL

Actual Results:

Library is named URLMock, which is totes boring.

Version:

1.0.1

Really just 7.0?

When I try to install I get:
(iOS 6.0) is not compatible with `URLMock (1.1.1)

Is this really only compatible with 7.0+

Add support for stream-based requests.

URLMock doesn’t work with stream-based requests, which means it’s not compatible with NSURLSession and is more difficult to use when memory is constrained.

Request hangs because URLMock doesn't read the HTTPBodyStream

Firstly, great work with this library! I heard about NSURLProtocol on Saul Mora's podcast, and immediately decided to make a 'MXMockURLProtocol'. Later I finished the podcast and discovered this library, which is exactly what I hoped to build!

I am having trouble with one of my requests, though. It's an upload of a file to Amazon S3 using AFHTTPRequestSerializer, it looks like this:

(lldb) po self.request
<NSURLRequest: 0x6180000045d0> { URL: https://mixim-unittest.s3.amazonaws.com/ }
(lldb) po [self.request allHTTPHeaderFields]
{
    "Accept-Language" = "en-GB;q=1, es;q=0.9, en;q=0.8, fr;q=0.7, de;q=0.6, zh-Hans;q=0.5";
    "Content-Length" = 411;
    "Content-Type" = "multipart/form-data; boundary=Boundary+1F6B675C1E398953";
    Expect = "100-continue";
    "User-Agent" = "Mixim/alpha6rc1-5-g006d85a-dirty (Mac OS X Version 10.9.4 (Build 13E28))";
}
(lldb) po [self.request HTTPBody]
 nil
(lldb) po [self.request HTTPBodyStream]
<AFMultipartBodyStream: 0x61800014aea0>

The request never completes. I think this is because the HTTP client is waiting for the body stream to be exhausted, because I subclassed UMKURLProtocol to add this:

- (void)startLoading
{
    // this is a patch for the mock URL protocol to prevent the client from hanging, waiting for the stream to be read
    NSInputStream *stream = [self.request HTTPBodyStream];

    if (stream) {
        uint8_t fakeBuffer[1024];

        while([stream read:fakeBuffer maxLength:1024] == 1024) {};
    }

    [super startLoading];
}

and that seemed to fix the hanging issue. But I suspect this is the wrong place to put this code!

Install Without CocoaPods

We have a large and complex project that contains multiple sets of xcconfig files which include each other to form a hierarchy. Xcode does not support inheriting values in xcconfig files like it does in the IDE. We cannot use CocoaPods in our project.

After trying to include your project as a sub-project in our own, I noticed that the directories and file structures do not seem to be in the final order. For example: URLMock.h contains the line #import <URLMock/UMKMockURLProtocol.h> but in the project's directory structure the file is actually at URLMock/Mock URL Protocol/UMKMockURLProtocol.h.

This makes it non-trivial to use URLMock without using CocoaPods.

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.