Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:06:28+00:00 2026-06-07T03:06:28+00:00

In my iOS app, I’m using a UIWebView and a custom protocol (with my

  • 0

In my iOS app, I’m using a UIWebView and a custom protocol (with my own NSURLProtocol implementation). I’ve been fairly careful about making sure that whenever I load a url, I load something like this into my UIWebView:

myprotocol://myserver/mypath

and in my NSURLProtocol implementation, I take a mutable copy of the NSURLRequest, convert the URL to http: and send that to my server.

Everything works for HTTP GET requests. The problem I encounter is with POST requests. It seems like the UIWebView doesn’t properly encode the form data in the HTTPBody if the request uses my custom protocol.

One work-around, since I’m using HTTPS for my server requests, is that I register my protocol handler to intercept http: instead of myprotocol: and I can convert all calls to https: This other question, here, pointed me toward that solution:

But I’m wondering if there’s any alternative and/or better way of accomplishing what I want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:06:31+00:00Added an answer on June 7, 2026 at 3:06 am

    Instead of trying to use POST requests, one work around is to continue using GET requests for myprotocol:// URLs, but transform them in your NSURLProtocol implementation to an http:// and POST request to your server using the request query string as the body of the POST.

    The worry with using GET requests to send large amounts of data is that somewhere along the request chain, the request line might get truncated. This appears to not be a problem, however, with locally-implemented protocols.

    I wrote a short Cordova test app to experiment and I found that I was able to send through a little over 1 MiB of data without trouble to the HTTP request echoing service http://http-echo.jgate.de/

    Here is my startLoading implementation:

    - (void)startLoading {
        NSURL *url = [[self request] URL];
        NSString *query = [url query];
        // Create a copy of `url` without the query string.
        url = [[[NSURL alloc] initWithScheme:@"http" host:@"http-echo.jgate.de" path:[url path]] autorelease];
        NSMutableURLRequest *newRequest = [NSMutableURLRequest requestWithURL:url];
        [newRequest setHTTPMethod:@"POST"];
        [newRequest setAllHTTPHeaderFields:[[self request] allHTTPHeaderFields]];
        [newRequest addValue:@"close" forHTTPHeaderField:@"Connection"];
        [newRequest addValue:@"application/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
        [newRequest setHTTPBody:[query dataUsingEncoding:NSUTF8StringEncoding]];
        urlConnection = [[NSURLConnection alloc] initWithRequest:newRequest delegate:self];
        if (urlConnection) {
            receivedData = [[NSMutableData data] retain];
        }
    }
    

    I then implemented the NSURLConnection protocol methods to forward to the appropriate NSURLProtocolClient method, but building up the response data in the case of Transfer-Encoding:chunked (as is the case for responses from http://http-echo.jgate.de/).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In an iOS app, I'm defining my own protocol to use the delegate pattern
My iOS app sends MIDI bank and program changes to other devices using PGMidi
I'm developing an iOS app using Core Plot headers. I have different UI for
I'm developing an iOS app with a UIWebView instance. If the user touches an
This app is using iOS 5's built-in dictionary with UISearchBar. I want to include
In an iOS app I'm developing, I show an UIWebView to allow the user
For my IOS app, i am using a tab bar controller on a mainstoryboard.
My iOS app has been rejected and I got the following message from Apple:
I'm making an iOS app like Kik messenger. I'm worried that the chat will
I have an iOS app which is using ASIHTTPRequest to talk to a REST

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.