1
This commit is contained in:
@@ -55,6 +55,7 @@ static NSUInteger kb_validUTF8PrefixLen(NSData *data) {
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
_httpMethod = @"GET";
|
||||
_acceptEventStream = NO;
|
||||
_disableCompression = YES;
|
||||
_treatSlashTAsTab = YES;
|
||||
@@ -83,7 +84,11 @@ static NSUInteger kb_validUTF8PrefixLen(NSData *data) {
|
||||
self.session = [NSURLSession sessionWithConfiguration:cfg delegate:self delegateQueue:[NSOperationQueue mainQueue]];
|
||||
|
||||
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:self.url];
|
||||
req.HTTPMethod = @"GET";
|
||||
NSString *method = self.httpMethod.length > 0 ? self.httpMethod : @"GET";
|
||||
req.HTTPMethod = method;
|
||||
if (self.httpBody.length > 0) {
|
||||
req.HTTPBody = self.httpBody;
|
||||
}
|
||||
if (self.disableCompression) { [req setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"]; }
|
||||
if (self.acceptEventStream) { [req setValue:@"text/event-stream" forHTTPHeaderField:@"Accept"]; }
|
||||
[req setValue:@"no-cache" forHTTPHeaderField:@"Cache-Control"];
|
||||
@@ -290,10 +295,10 @@ static NSUInteger kb_validUTF8PrefixLen(NSData *data) {
|
||||
if (rawText.length == 0) return;
|
||||
// 调试:在任何处理之前打印后端“原始文本分片”,便于对照排查
|
||||
if (self.loggingEnabled) {
|
||||
NSLog(@"[KBStream] RAW chunk#%ld len=%lu text=\"%@\"",
|
||||
(long)(self.emittedChunkCount + 1),
|
||||
(unsigned long)rawText.length,
|
||||
KBPrintableSnippet(rawText, 160));
|
||||
// NSLog(@"[KBStream] RAW chunk#%ld len=%lu text=\"%@\"",
|
||||
// (long)(self.emittedChunkCount + 1),
|
||||
// (unsigned long)rawText.length,
|
||||
// KBPrintableSnippet(rawText, 160));
|
||||
}
|
||||
NSString *text = rawText;
|
||||
// 0) 规范化换行与段起始:去掉位于片段开头的 \r/\n;将 "\n\t"、"\r\n\t"、"\r\t" 归一为 "\t"
|
||||
|
||||
Reference in New Issue
Block a user