Re: HTTPS streams through a proxy

132 篇文章 0 订阅

转自: http://lists.apple.com/archives/macnetworkprog/2004/May/msg00040.html

Re: HTTPS streams through a proxy


  • SubjectRe: HTTPS streams through a proxy
  • From: Becky Willrich <email@hidden>
  • Date: Thu, 13 May 2004 17:03:26 -0700

We could use:
CFDictionaryRef proxyDict = SCDynamicStoreCopyProxies(NULL);

CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy,
proxyDict);

But we need to be able to use specific proxy settings, independently
from the settings in the panel.

I am yet unsure on how to modify the proxyDict(if possible) so that it
would use the right settings for the proxy, or is there another way to
do this?

You are on the right track - CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxyDict) is the right call for configuring the HTTP(S) proxy; you just have to figure out what the right content for proxyDict is. If you just pass through SCDynamicStoreCopyProxies(NULL) as above, you get the default proxies as the user has configured them on the system. To create custom proxy settings, you can either make a mutable copy of the proxy dict returned by SCDynamicStoreCopyProxies() then change the settings you want, or you can create a new dictionary from scratch. To create a new dictionary from scratch, just use the keys given in CFHTTPStream.h. That will look something like this:

CFTypeRef keys[2], values[2];
keys[0] = kCFStreamPropertyHTTPSProxyHost;
values[0] = myHTTPSProxyHost;
keys[1] = kCFStreamPropertyHTTPSProxyPort;
values[1] = CFNumberCreate(NULL, kCFNumberSInt32Type, &myHTTPSProxyPortNumber);
proxyDict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxyDict);

This sets the HTTPS proxy to be whatever host is in myHTTPSProxyHost (should be a CFString) and whatever port is in myHTTPSProxyPortNumber.

Hope that helps,
REW
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:  http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值