ixudra / curl

Custom PHP curl library for the Laravel 5 framework - developed by Ixudra
MIT License
561 stars 128 forks source link

response there is apache status #116

Closed eraporsmk closed 4 years ago

eraporsmk commented 4 years ago

Server Code

$query = Kompetensi_dasar::whereHas('mata_pelajaran_kurikulum.kurikulum', function($sq) use ($request){
            $sq->whereIn('jurusan_id', $request->updated_at);
        })->where('created_at', '>', $request->last_sync)->get();
        $data['dapodik'] = $query;
        return response()->json($data, 200);

Local code

$curl = Curl::to($url_to_server)
        ->withHeader('x-api-key:key_here')
        ->withOption('USERPWD', "user:pass")
        ->returnResponseObject()
        ->withData($arguments)
        ->withTimeout(0)
        ->post();

Server response

{#1346 ▼
  +"content": """
    {"dapodik":[{"kompetensi_dasar_id":"32a3d702-4d99-41e2-a08d-b8627aec645f","id_kompetensi":"3.18","kompetensi_id":1,"mata_pelajaran_id":100011070,"kelas_10":1,"k ▶
    Date: Sun, 24 Nov 2019 05:49:41 GMT

    Server: Apache/2.4.39 (Win64) OpenSSL/1.1.1c PHP/7.2.21

    Vary: Authorization

    X-Powered-By: PHP/7.2.21

    Cache-Control: no-cache, private

    X-RateLimit-Limit: 60

    X-RateLimit-Remaining: 59

    Content-Length: 4410

    Content-Type: application/json

    {"dapodik":[{"kompetensi_dasar_id":"32a3d702-4d99-41e2-a08d-b8627aec645f","id_kompetensi":
    """
  +"status": 200
  +"contentType": "application/json"
}

Why in response there is Date: Sun, 24 Nov 2019 05:49:41 GMT Etc...

elimentz commented 4 years ago

Those are your response headers. They contain information about the request provided by the server which you may or may not need for response handling. In your case you don't but it's not wrong or abnormal.

That said, those shouldn't be in there unless you use the ->withResponseHeaders() method. Can you check which version of the package you have installed?

eraporsmk commented 4 years ago

Laravel: 5.8.35 ixudra/curl: 6.17.0

elimentz commented 4 years ago

Not the latest version but still pretty recent. You might consider updating, though I doubt it will make any difference. I recommend checking if you use the ->withResponseHeaders() method somewhere, else I can't really explain why the headers are included.