Having an embedded HTTP Server in an iOS application, How can I respond to an HTTP Request with a multipart message?
I'd like to asynchronously send JPEGs in a multipart response (MJPEG).
I've tried doing so using GCDWebServer, if it's not supported by it, any working alternative would be fine as long as it can also work on iOS.
GCDWebServer has no built-in API to create multipart messages. You would need to write such code and output a NSData object, which then you wrap into a GCDWebServerDataResponse that you return to the HTTP client.
Related
My project has three part e.g. Lumen-5.8(API), Angular-8(web), Android(Mobile). The POST method is working in Angular but not working in Android.
You are developing API. So you need to care about request and response type.
Ex. In Android, If you are expecting string response from API but your API send you integer then you will get 500 error.
I am using the Alamofire 4.0.1 library in swift 3; I am looking for the HTTP Status-Line (as described in https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html). I can get the status code, the headers, everything, but not the status message.
I am querying a REST API which gives me 403 responses with different messages after the "Forbidden" keyword describing the problem: like the client is not approved for access or that accessing an specific URL is not allowed, because it is for internal use only. In my client accessing the API I want to give the user more details than just the "Forbidden" message.
This is what the server sends back (I know this because I used Paw, a HTTP Client to send a HTTP request and investigate the response):
HTTP/1.0 403 Forbidden (internal method)
So to conclude, is there any chance to get the HTTP Status-Line in Alamofire?
Unfortunately no
Alamofire uses the URLResponse and it does not implement any field/method that gives you information about Status-Line. To get the Status-Line you should use other maybe lower-level frameworks.
URLResponse gives you only information about allHeaderFields, you can look on my answer about it here :
https://stackoverflow.com/a/36524454/5433235
On my Twilio number I have a Request URL configured for Messaging. The problem is I need the HTTP Post from Twilio in json but there doesn't seem to be a way to configure it.
Hi Twilio developer evangelist here.
Unfortunately there will be no way for you to configure Twilio to post a JSON request to your server. What you can do however is post to a different server that will take that request, turn it into JSON and then make a request to your original endpoint with a JSON packet.
That's obviously if you can't just convert the POST request into JSON on your original server, which is preferable.
Let me know if you have any more questions.
Can somebody post some code example(code or link) of how to http authenticate from iphone objective c using xcode?
I wanna to go to my web application passing through POST login and passord and be able to return the response to validate it is authenticated or not
thanks
Sounds like you're doing form-based authentication, passing credentials as POST variables. If you already have a third-party networking wrapper you're using (such as AFNetworking), read its documentation to find out what facilities it has for sending POST variables.
If you want to roll your own, the basic process is:
Create an NSMutableURLRequest with the login URL
Use the setHTTPMethod: method to set the request's method to "POST"
Escape and concatenate your credentials to construct a well-formed POST body
Set the POST body of the request object with setHTTPBody:
Send the request with an NSURLConnection and receive the response using its synchronous or asynchronous API.
Can somebody post some code example(code or link) of how to http authenticate from iphone objective c using Xcode?
See the Advanced URL Connections sample project Apple provides in the iOS developer centre.
I wanna to go to my web application passing through POST login and passord and be able to return the response to validate it is authenticated or not
That's not HTTP authentication. That's just a normal HTTP POST.
I don't know how to make Http connection with HTTP server using blackberry. I want to send argument with URL and I have to get a response from the server using Http connection I don't how to do this.pls provide me with some code snippet to handle this situation.