我正在尝试创建一个C#代理DLL,允许VS2015社区在我的离线工作站上通过具有身份验证的公司HTTP代理访问Internet.
按照这篇MSDN博客文章的说明, 我能够以这种方式将VisualStudio连接到HTTP页面:
namespace VSProxy
{
public class AuthProxyModule : IWebProxy
{
ICredentials crendential = new NetworkCredential("user", "password");
public ICredentials Credentials
{
get
{
return crendential;
}
set
{
crendential = value;
}
}
public Uri GetProxy(Uri destination)
{
ServicePointManager.ServerCertificateValidationCallback = (Header, Cer, Claim, SslPolicyErrors) => true;
return new Uri("http://128.16.0.123:1234", UriKind.Absolute);
}
public bool IsBypassed(Uri host)
{
return host.IsLoopback;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我无法连接到Visual Studio社区访问的帐户身份验证页面.
所以,我正在尝试使用DLL验证Microsoft证书.
我有什么方法可以完成HTTPS和证书问题?
如何验证webProxy DLL中的证书?
错误出现在ShowMessage(aServer.mc_version)
此代码的行中:
uses mantisconnect;
procedure TForm.Button1Click(Sender: TObject);
var
aServer: MantisConnectPortType;
begin
aServer := GetMantisConnectPortType;
ShowMessage('Mantis version:' + aServer.mc_version);
end;
Run Code Online (Sandbox Code Playgroud)
相同的代码适用于Delphi XE5,但是在Delphi XE6上编译时第一次触发错误(首次单击按钮),但下次有效:
The system cannot find the file specified
URL:http://www.mymantis.com/api/soap/mantisconnect.php -
SOAPAction: URL:http://www.mymantis.com/api/soap/mantisconnect.php/mc_version
Run Code Online (Sandbox Code Playgroud)
如果我再试一次(第二次点击按钮)就行了!输出:
Mantis version:1.2.9
Run Code Online (Sandbox Code Playgroud)
连接过程列表是
function GetMantisConnectPortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): MantisConnectPortType;
const
defWSDL = 'http://www.mymantis.com/api/soap/mantisconnect.php?wsdl';
defURL = 'http://www.mymantis.com/api/soap/mantisconnect.php';
defSvc = 'MantisConnect';
defPrt = 'MantisConnectPort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr …
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个用于将视频上传到YouTube的服务器应用程序.在我的服务器应用程序中,用户可以将视频直接上传到我的YouTube频道以公开.
为了使这项工作,我创建了一个虚拟Web应用程序,可以捕获生成的刷新令牌,并将其存储在一个key.txt
文件中
{"access_token":"MYTOKEN","token_type":"Bearer","expires_in":3600,"created":1435654774}
Run Code Online (Sandbox Code Playgroud)
该upload_video.php
脚本会自动更新"key.txt"
,如果文件access_token
是过时的.这是来自的代码upload_video.php
:
$key = file_get_contents('key.txt');
$application_name = 'YouTube_Upload';
$client_secret = 'MY_CLIENT_SECRET';
$client_id = 'MY_CLIENT_ID';
$scope = array('https://www.googleapis.com/auth/youtube.upload', 'https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/youtubepartner');
$videoPath = "Test.f4v";
$videoTitle = "A tutorial video";
$videoDescription = "A video tutorial on how to upload to YouTube";
$videoCategory = "22";
$videoTags = array("youtube", "tutorial");
try{
// Client init
$client = new Google_Client();
$client->setApplicationName($application_name);
$client->setClientId($client_id);
$client->setAccessType('offline');
$client->setAccessToken($key);
$client->setScopes($scope);
$client->setClientSecret($client_secret);
if ($client->getAccessToken()) {
/**
* Check …
Run Code Online (Sandbox Code Playgroud) 我做了一个简单的电子应用程序:
main.js
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
let win
function createWindow () {
win = new BrowserWindow({
width: 800,
height: 600,
icon: path.join(__dirname, 'icon.ico')
})
win.maximize();
win.loadURL('https://stackoverflow.com/', {"extraHeaders" : "pragma: no-cache\n"});
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('browser-window-created',function(e,window) {
window.setMenu(null);
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
}) …
Run Code Online (Sandbox Code Playgroud) 由于防火墙审核,请求必须始终具有"UserAgent"和"Accept"标头.
我试过这个:
$soapclient = new soapclient('http://www.soap.com/soap.php?wsdl',
array('stream_context' => stream_context_create(
array(
'http'=> array(
'user_agent' => 'PHP/SOAP',
'accept' => 'application/xml')
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
服务器soap收到的请求
GET /soap.php?wsdl HTTP/1.1
Host: www.soap.com
User-Agent: PHP/SOAP
Connection: close
Run Code Online (Sandbox Code Playgroud)
预期的结果
GET /soap.php?wsdl HTTP/1.1
Host: www.soap.com
Accept application/xml
User-Agent: PHP/SOAP
Connection: close
Run Code Online (Sandbox Code Playgroud)
为什么没有发送"接受"?"用户代理"有效!
我有一个src/assets/version.json
包含此内容的 json 文件:
{"VERSION":"1.0.0"}
Run Code Online (Sandbox Code Playgroud)
然后我将文件导入到*.ts
,例如:
import * as VersionInfo from 'src/assets/version.json';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor() {
console.log(`version ${VersionInfo['VERSION']}`);
}
}
Run Code Online (Sandbox Code Playgroud)
输出
version 1.0.0
Run Code Online (Sandbox Code Playgroud)
这适用于 Angular 11,但在 Angular 12 上,CLI 显示错误
Should not import the named export 'VERSION' (imported as 'VersionInfo') from default-exporting module (only default export is available soon)
Run Code Online (Sandbox Code Playgroud)
这是我的 tsconfig.base.json
{
"compileOnSave": false,
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"strictPropertyInitialization": false,
"baseUrl": "./",
"importHelpers": true,
"outDir": …
Run Code Online (Sandbox Code Playgroud) 升级到Symfony后,我发现了很多弃用警告:
"Symfony\Bundle\AsseticBundle\Config\AsseticResource"类通过ResourceInterface :: isFresh()执行资源检查,自2.8以来不推荐使用,将在3.0中删除(54次)
堆栈(来自Symfony profiler)
BCResourceInterfaceChecker::isFresh() (called from bootstrap.php.cache at line 3061)
ResourceCheckerConfigCache::isFresh() (called from ResourceCheckerConfigCacheFactory.php at line 45)
ResourceCheckerConfigCacheFactory::cache() (called from classes.php at line 1328)
Router::getMatcher() (called from classes.php at line 1288)
Router::match() (called from classes.php at line 7170)
Router::match() (called from classes.php at line 2086)
RouterListener::onKernelRequest()
call_user_func() (called from WrappedListener.php at line 61)
WrappedListener::__invoke()
call_user_func() (called from classes.php at line 1853)
EventDispatcher::doDispatch() (called from classes.php at line 1771)
EventDispatcher::dispatch() (called from TraceableEventDispatcher.php at line 132)
TraceableEventDispatcher::dispatch() (called …
Run Code Online (Sandbox Code Playgroud) Data.Cloud.CloudAPI.pas
有class function TCloudSHA256Authentication.GetStreamToHashSHA256Hex(const Content: TStream): string;
这回错了SHA 256上的一些文件.
class function TCloudSHA256Authentication.GetStreamToHashSHA256Hex(const Content: TStream): string;
var
LBytes : TBytes;
Hash: THashSHA2;
begin
LBytes := TBytesStream(Content).Bytes;
//Hash bytes
Hash := THashSHA2.Create;
Hash.Update(LBytes);
Result := Hash.HashAsString;
end;
Run Code Online (Sandbox Code Playgroud)
AWS S3返回错误:
提供的x-amz-content-sha256标头与计算的不匹配
GetStreamToHashSHA256Hex似乎与亚马逊产生了不同的sha256:
<ClientComputedContentSHA256>f43ee89e2b7758057bb1f33eb8546d4c2c118f2ab932de89dbd74aabc0651053</ClientComputedContentSHA256>
<S3ComputedContentSHA256>3bbf5f864cc139cf6392b4623bd782a69d16929db713bffaa68035f8a5c3c0ce</S3ComputedContentSHA256>
Run Code Online (Sandbox Code Playgroud)
我用myfile.zip做了一些测试(600 MB)...
TIdHashSHA256
Indy的另一种选择返回正确的SHA256(与aws s3相同),例如:
var
aFileStream: TFileStream;
aHash: TIdHashSHA256;
begin
aFileStream := TFileStream.Create('C:\myfile.zip', fmOpenRead or fmShareDenyWrite);
aHash := TIdHashSHA256.Create;
try
Result := aHash.HashStreamAsHex(aFileStream).ToLower;
finally
aFileStream.Free;
aHash.Free;
end;
end;
Run Code Online (Sandbox Code Playgroud)
hash_file()
从PHP返回正确的SHA256(与aws s3相同),例如:
hash_file('sha256', 'C:\myfile.zip');
Run Code Online (Sandbox Code Playgroud)
但THashSHA2返回错误的sha256,例如:
var
LBytes : …
Run Code Online (Sandbox Code Playgroud) 我实施了一个显示小吃店的"小吃吧服务" :
snackbar.service.ts
import { Subscription } from 'rxjs/Subscription';
import { Subject } from 'rxjs/Subject';
import { Inject, Injectable, OnDestroy } from '@angular/core';
import { MatSnackBar, MdSnackBarConfig } from '@angular/material/snack-bar';
import { MdSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
export class SnackBarMessage {
message: string;
action: string = null;
config: MdSnackBarConfig = null;
}
@Injectable()
export class SnackBarService implements OnDestroy
{
private messageQueue: Subject<SnackBarMessage> = new Subject<SnackBarMessage>();
private subscription: Subscription;
private snackBarRef: MdSnackBarRef<SimpleSnackBar>;
constructor(public snackBar: MatSnackBar){
this.subscription = this.messageQueue.subscribe(message => …
Run Code Online (Sandbox Code Playgroud) 我发现svn错误消息的信息很差155009
:
无法运行与"C:\ Users\XXX\Foo"关联的WC DB工作队列,工作项82(文件安装Bar.dll 1 0 1 1)无法打开文件'C:\ Users\XXX\Foo .svn\pristine\c2\c2dbd0fd0b44d0e4915581196479ada5567b0750.svn-base':系统找不到指定的文件
我在Windows 7上使用1.8.11 svn libs(由Tortoise安装).
帮助我理解问题以及如何解决问题......
php ×3
angular ×2
delphi ×2
javascript ×2
soap ×2
amazon-s3 ×1
angular12 ×1
c# ×1
delphi-xe6 ×1
electron ×1
google-api ×1
google-oauth ×1
http ×1
http-headers ×1
mantis ×1
proxy ×1
ssl ×1
svn ×1
symfony ×1
symfony-2.8 ×1
typescript ×1
youtube-api ×1