-
-
Notifications
You must be signed in to change notification settings - Fork 876
Need a way to add HTTP Headers #877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This sounds like a good feature request. In terms of headers, let me ask you few questions:
|
Okay. Let me add some information. The required headers are dependent to the user, so the headers could be changed. Not have to be changed per every request but can be changed at some point after the initialization time. |
This is challenging, though we probably can find a way to make this work. |
Yes. If the commandRunner instance is accessible and it provides an API to set headers, it will be enough. |
Would a fork work in your case then? |
I'm not sure how to get the instance of PFURLSessionCommandRunner. |
I found a way to get the instance of PFURLSessionCommandRunner.
But that commandRunner is a singleton and has fixed headers already set. So I will not be able to change the headers later. I think the following way might be possible.
I think I could get the PFCommandURLRequestConstructor by |
Bump, @conanoc were you able to find a work around for this? |
This could be paired/a response to the parse-server's issue #1059 ? |
@jakeblakeley not yet. |
I end up use swizzling as an adhoc way.
|
I am trying to get Gzip working for all parse requests. I enabled and tested compression on my heroku-hosted Parse instance and all is good. However, my iOS app isn't setting Accept Encoding: Gzip. Am I doing something stupid or is this another instance where custom headers would help? |
@seejayuu I remember testing this a long time ago (GZIP is enabled on all Parse.com responses over 1KB IIRC), and it seemed like It's possible that |
@seejayuu NSURLSession also sends Accept Encoding: Gzip header by defaults. You don't have to do anything to enable gzip in your ios app. You could see your packets gzipped if you capture them by packet sniffers. |
I found the problem. The node.js/express migration Parse version that I am hosting on Heroku does not enable gzip on the server side. I corrected that and now all is good.
|
Hi Guys Parse.initialize(new Parse.Configuration.Builder(this).server(Config.PARSE_SERVER_URL)
.applicationId(Config.PARSE_APPLICATION_ID)
.clientKey("")
.addNetworkInterceptor(chain -> {
ParseHttpRequest request = chain.getRequest();
ParseHttpRequest.Builder builder =
new ParseHttpRequest.Builder(request).addHeader(Config.HEADER_KEY,
Config.HEADER_VALUE);
return chain.proceed(builder.build());
})
.enableLocalDataStore()
.build()); But I don't know how to do in iOS. Please help if any of you has the answer. Thank you. |
@swami701 Have you tried the above code (LynkRequestConstructor) that I had put as a comment? Swizzling can be used to intercept something. |
In lib/cli/parse-server, add: app.use(require(‘compression’)); before: app.use(options.mountPath, api);
|
Thank @seejayuu for your answer. I still got the error respond "incorrect header check" when I do REST API request with Content-Encoding = gzip. Please help to share how you enable it in your server. "I found the problem. The node.js/express migration Parse version that I am hosting on Heroku does not enable gzip on the server side. I corrected that and now all is good." Thank again!! |
I end up using cloudFlare, it is support gzip. thank all |
Hi @conanoc , can you please provide the sample code how to use LynkRequestConstructor in initializing the parse? Thanks! |
@wooiliang Just call [LynkRequestConstructor swizzleMethod]; and it should be called only once. |
This issue has been automatically marked as stale because it has not had recent activity. If you believe it should stay open, please let us know! As always, we encourage contributions, check out the Contributing Guide |
I need a way to add custom HTTP headers to parse http requests.
Parse android SDK has an API to add "network interceptors" which can modify request object (or response object either).
It will be good if I can add or remove headers at any point before making requests. I can only set network interceptors at initialization time on android SDK.
The text was updated successfully, but these errors were encountered: