修改sign。
键盘里ai回复的bug
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#import "KBHostAppLauncher.h"
|
||||
#import "KBInputBufferManager.h"
|
||||
#import "KBResponderUtils.h" // 统一查找 UIInputViewController 的工具
|
||||
#import "KBSignUtils.h"
|
||||
#import "KBSkinManager.h"
|
||||
#import "KBStreamOverlayView.h" // 带关闭按钮的流式层
|
||||
#import "KBStreamTextView.h" // 流式文本视图
|
||||
@@ -435,11 +436,32 @@
|
||||
cachePolicy:NSURLRequestReloadIgnoringCacheData
|
||||
timeoutInterval:60];
|
||||
request.HTTPMethod = @"POST";
|
||||
[request setValue:@"text/event-stream" forHTTPHeaderField:@"Accept"];
|
||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
// 签名头(后端要求,否则会 401:Missing sign headers)
|
||||
NSDictionary<NSString *, NSString *> *signHeaders =
|
||||
[KBSignUtils signHeadersWithBodyParams:payload];
|
||||
[signHeaders enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *obj,
|
||||
BOOL *stop) {
|
||||
if (key.length == 0 || obj.length == 0) {
|
||||
return;
|
||||
}
|
||||
[request setValue:obj forHTTPHeaderField:key];
|
||||
}];
|
||||
NSString *token = KBAuthManager.shared.current.accessToken ?: @"";
|
||||
if (token.length > 0) {
|
||||
[request setValue:token forHTTPHeaderField:@"auth-token"];
|
||||
}
|
||||
// 与主 App 的请求头保持一致(Bearer)
|
||||
NSDictionary<NSString *, NSString *> *authHeader =
|
||||
[[KBAuthManager shared] authorizationHeader];
|
||||
[authHeader enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *obj,
|
||||
BOOL *stop) {
|
||||
if (key.length == 0 || obj.length == 0) {
|
||||
return;
|
||||
}
|
||||
[request setValue:obj forHTTPHeaderField:key];
|
||||
}];
|
||||
request.HTTPBody = bodyData;
|
||||
|
||||
self.streamHasOutput = NO;
|
||||
@@ -463,7 +485,7 @@
|
||||
__strong typeof(weakSelf) self = weakSelf;
|
||||
if (!self)
|
||||
return;
|
||||
[self kb_handleEventSourceError:event.error];
|
||||
// [self kb_handleEventSourceError:event.error];
|
||||
}
|
||||
forEvent:WJXEventNameError
|
||||
queue:NSOperationQueue.mainQueue];
|
||||
|
||||
Reference in New Issue
Block a user